From c35e40893b3720c87ec5af33cc0283434afe80ba Mon Sep 17 00:00:00 2001 From: Joachim Nielandt Date: Thu, 18 May 2023 11:53:33 +0200 Subject: [PATCH] Added shutdown mode --- dot_config/sway/config | 28 +++++++++---------- dot_config/sway/keybinding.conf | 2 ++ dot_config/sway/modes.conf | 48 ++++++++++++++++++++++++++++++--- 3 files changed, 60 insertions(+), 18 deletions(-) diff --git a/dot_config/sway/config b/dot_config/sway/config index 6a0b930..4a88de1 100644 --- a/dot_config/sway/config +++ b/dot_config/sway/config @@ -82,20 +82,20 @@ assign [class="Thunderbird"] $ws2 # lock / logout / sleep / hibernate / restart / poweroff # TODO convert this to swaylock -set $mode_system "System  l e s鈴 h rﰇ וּsﮤ" -mode $mode_system { - bindsym l exec --no-startup-id ~/.config/i3/i3exit.sh lock, mode "default" - bindsym e exec --no-startup-id ~/.config/i3/i3exit.sh logout, mode "default" - bindsym s exec --no-startup-id systemctl suspend, mode "default" - bindsym h exec --no-startup-id ~/.config/i3/i3exit.sh hibernate, mode "default" - bindsym r exec --no-startup-id ~/.config/i3/i3exit.sh reboot, mode "default" - bindsym Shift+s exec --no-startup-id ~/.config/i3/i3exit.sh shutdown, mode "default" - # back to normal: Enter or Escape - bindsym Return mode "default" - bindsym Escape mode "default" -} -bindsym $mod+Pause mode $mode_system -bindsym $mod+F12 mode $mode_system +#set $mode_system "System  l e s鈴 h rﰇ וּsﮤ" +#mode $mode_system { +# bindsym l exec --no-startup-id ~/.config/i3/i3exit.sh lock, mode "default" +# bindsym e exec --no-startup-id ~/.config/i3/i3exit.sh logout, mode "default" +# bindsym s exec --no-startup-id systemctl suspend, mode "default" +# bindsym h exec --no-startup-id ~/.config/i3/i3exit.sh hibernate, mode "default" +# bindsym r exec --no-startup-id ~/.config/i3/i3exit.sh reboot, mode "default" +# bindsym Shift+s exec --no-startup-id ~/.config/i3/i3exit.sh shutdown, mode "default" +# # back to normal: Enter or Escape +# bindsym Return mode "default" +# bindsym Escape mode "default" +#} +#bindsym $mod+Pause mode $mode_system +#bindsym $mod+F12 mode $mode_system # do a nice menu for keyboard layouts # TODO convert to wayland, using dconf-editor perhaps? diff --git a/dot_config/sway/keybinding.conf b/dot_config/sway/keybinding.conf index ad3366a..9cdf7bf 100644 --- a/dot_config/sway/keybinding.conf +++ b/dot_config/sway/keybinding.conf @@ -148,3 +148,5 @@ $bindsym --locked XF86AudioMute exec $volume_mute # modes ## Launch // Resize Mode ## $bindsym $mod+r mode $mode_resize +## Launch // Exit Menu ## +$bindsym $mod+F12 mode $mode_shutdown diff --git a/dot_config/sway/modes.conf b/dot_config/sway/modes.conf index 3f7a62a..7da89be 100644 --- a/dot_config/sway/modes.conf +++ b/dot_config/sway/modes.conf @@ -1,8 +1,11 @@ +set $mode_color_foreground $light0 +set $mode_color_action $bright_green + # RESIZE -set $mode_resize " \ -Resize (↑ ↓ ← →) \ -Increase Gaps (+) \ -Decrease Gaps (-)" +set $mode_resize " \ +Resize (↑ ↓ ← →) \ +Increase Gaps (+) \ +Decrease Gaps (-)" mode --pango_markup $mode_resize { # left will shrink the containers width @@ -37,3 +40,40 @@ mode --pango_markup $mode_resize { $bindsym Return mode "default" $bindsym Escape mode "default" } + +# SHUTDOWN +set $mode_shutdown "\ + \ + \ +(h)hibernate \ +(l)lock \ +(e)logout \ +(r)reboot \ +(u)suspend \ +(s)shutdown \ +" + +set $purge_cliphist [ $purge_cliphist_logout == 'true' ] && rm -f $HOME/.cache/cliphist/db || exit 0 + +mode --pango_markup $mode_shutdown { + # lock + $bindsym l mode "default", exec $locking + + # logout + $bindsym e exec $purge_cliphist; exec loginctl terminate-user $USER + + # suspend + $bindsym u mode "default", exec systemctl suspend + + # hibernate + $bindsym h mode "default", exec systemctl hibernate + + # shutdown + $bindsym s exec $purge_cliphist; exec systemctl poweroff + + # reboot + $bindsym r exec $purge_cliphist; exec systemctl reboot + + # Return to default mode. + $bindsym Escape mode "default" +}