Commit f062e4882055bfe9ab947a5c85e0879b9db29afe Parent: 03e587fff15c900255b4dbe0eb5fe09c33890581 Author: mcol <mcol@posteo.net> Date: 2021-10-18 00:37:55 +0100 Committer: mcol <mcol@posteo.net> Committed: 2021-10-18 00:37:55 +0100 Add the qtile-extras power menu!
power_menu.py Added
@@ -0,0 +1,82 @@ +from qtile_extras.popup.toolkit import ( + PopupRelativeLayout, + PopupImage, + PopupText +) + +from libqtile.lazy import lazy + + +def show_power_menu(qtile): + controls = [ + PopupImage( + filename="~/pictures/icons/lock.svg", + pos_x=0.15, + pos_y=0.1, + width=0.1, + height=0.5, + mouse_callbacks={ + "Button1": + lazy.spawn("swaylock") + } + ), + PopupImage( + filename="~/pictures/icons/sleep.svg", + pos_x=0.45, + pos_y=0.1, + width=0.1, + height=0.5, + mouse_callbacks={ + "Button1": + lazy.spawn("systemctl suspend", shell=True) + } + ), + PopupImage( + filename="~/pictures/icons/shutdown.svg", + pos_x=0.75, + pos_y=0.1, + width=0.1, + height=0.5, + highlight="A00000", + mouse_callbacks={ + "Button1": + lazy.spawn("backup-home-and-poweroff") + } + ), + PopupText( + text="Lock", + pos_x=0.1, + pos_y=0.7, + width=0.2, + height=0.2, + h_align="center" + ), + PopupText( + text="Sleep", + pos_x=0.4, + pos_y=0.7, + width=0.2, + height=0.2, + h_align="center" + ), + PopupText( + text="Shutdown", + pos_x=0.7, + pos_y=0.7, + width=0.2, + height=0.2, + h_align="center" + ), + ] + PopupRelativeLayout( + qtile, + width=1000, + height=200, + controls=controls, + background="00000060", + initial_focus=2, + ).show(centered=True) + +keys_power_menu = [ + ([], 'XF86PowerOff', lazy.function(show_power_menu), "Display the power menu.") +]
config.py Modified
@@ -38,6 +38,9 @@ reload("scratchpad") from scratchpad import keys_scratchpad, scratchpad +reload("power_menu") +from power_menu import keys_power_menu + IS_WAYLAND: bool = qtile.core.name == "wayland" IS_XEPHYR: bool = int(os.environ.get("QTILE_XEPHYR", 0)) > 0 @@ -96,6 +99,7 @@ my_keys.extend(keys_backend) my_keys.extend(keys_group) my_keys.extend(keys_scratchpad) +my_keys.extend(keys_power_menu) reload("fullscreen_state") from fullscreen_state import toggle_fullscreen_state