My Qtile window manager configuration
git clone https://github.com/m-col/qtile-config
Files | Refs | Readme

-rw-r--r-- power_menu.py


      1 from libqtile.lazy import lazy
      2 from qtile_extras.popup.toolkit import PopupImage, PopupRelativeLayout, PopupText
      3 
      4 
      5 def show_power_menu(qtile):
      6     controls = [
      7         PopupImage(
      8             filename="~/pictures/icons/lock.svg",
      9             pos_x=0.15,
     10             pos_y=0.1,
     11             width=0.1,
     12             height=0.5,
     13             mouse_callbacks={"Button1": lazy.spawn("swaylock")},
     14         ),
     15         PopupImage(
     16             filename="~/pictures/icons/sleep.svg",
     17             pos_x=0.45,
     18             pos_y=0.1,
     19             width=0.1,
     20             height=0.5,
     21             mouse_callbacks={"Button1": lazy.spawn("systemctl suspend", shell=True)},
     22         ),
     23         PopupImage(
     24             filename="~/pictures/icons/shutdown.svg",
     25             pos_x=0.75,
     26             pos_y=0.1,
     27             width=0.1,
     28             height=0.5,
     29             highlight="A00000",
     30             mouse_callbacks={"Button1": lazy.spawn("backup-home-and-poweroff")},
     31         ),
     32         PopupText(
     33             text="Lock", pos_x=0.1, pos_y=0.7, width=0.2, height=0.2, h_align="center"
     34         ),
     35         PopupText(
     36             text="Sleep", pos_x=0.4, pos_y=0.7, width=0.2, height=0.2, h_align="center"
     37         ),
     38         PopupText(
     39             text="Shutdown",
     40             pos_x=0.7,
     41             pos_y=0.7,
     42             width=0.2,
     43             height=0.2,
     44             h_align="center",
     45         ),
     46     ]
     47     PopupRelativeLayout(
     48         qtile,
     49         width=1000,
     50         height=200,
     51         controls=controls,
     52         background="000000c0",
     53         initial_focus=2,
     54     ).show(centered=True)
     55 
     56 
     57 keys_power_menu = [
     58     ([], "XF86PowerOff", lazy.function(show_power_menu), "Display the power menu.")
     59 ]
     60