Added dmenuexit.

This commit is contained in:
dabruh 2022-06-03 20:14:32 +02:00
parent 039fbb1700
commit eb8f87339d
3 changed files with 41 additions and 52 deletions

View File

@ -171,58 +171,15 @@ bindsym $mod+Shift+c reload
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3) # restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Shift+r restart bindsym $mod+Shift+r restart
# exit i3 (logs you out of your X session) # Exit control
bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'" bindsym $mod+Shift+e exec --no-startup-id dmenuexit
# Resize window
bindsym $mod+y resize shrink width 5 px or 5 ppt bindsym $mod+y resize shrink width 5 px or 5 ppt
bindsym $mod+u resize grow height 5 px or 5 ppt bindsym $mod+u resize grow height 5 px or 5 ppt
bindsym $mod+i resize shrink height 5 px or 5 ppt bindsym $mod+i resize shrink height 5 px or 5 ppt
bindsym $mod+o resize grow width 5 px or 5 ppt bindsym $mod+o resize grow width 5 px or 5 ppt
# resize window (you can also use the mouse for that)
mode "resize" {
# These bindings trigger as soon as you enter the resize mode
# Pressing left will shrink the windows width.
# Pressing right will grow the windows width.
# Pressing up will shrink the windows height.
# Pressing down will grow the windows height.
bindsym h resize shrink width 5 px or 5 ppt
bindsym j resize grow height 5 px or 5 ppt
bindsym k resize shrink height 5 px or 5 ppt
bindsym l resize grow width 5 px or 5 ppt
# same bindings, but for the arrow keys
bindsym Left resize shrink width 5 px or 5 ppt
bindsym Down resize grow height 5 px or 5 ppt
bindsym Up resize shrink height 5 px or 5 ppt
bindsym Right resize grow width 5 px or 5 ppt
# back to normal: Enter or Escape or $mod+r
bindsym Return mode "default"
bindsym Escape mode "default"
bindsym $mod+r mode "default"
}
bindsym $mod+r mode "resize"
mode "system" {
bindsym l exec --no-startup-id i3exit lock, mode "default"
bindsym s exec --no-startup-id i3exit suspend, mode "default"
bindsym h exec --no-startup-id i3exit hibernate, mode "default"
bindsym u exec --no-startup-id i3exit switch_user, mode "default"
bindsym Shift+l exec "i3-nagbar -t warning -m 'Are you sure you want to log out?' -B 'Yes' 'i3exit logout'"
bindsym p exec "i3-nagbar -t warning -m 'Are you sure you want to power off?' -B 'Yes' 'poweroff'"
bindsym r exec "i3-nagbar -t warning -m 'Are you sure you want to reboot?' -B 'Yes' 'reboot'"
# back to normal: Enter or Escape or $mod+r
bindsym Return mode "default"
bindsym Escape mode "default"
bindsym $mod+Shift+s mode "default"
}
bindsym $mod+Shift+s mode "system"
# Start i3bar to display a workspace bar (plus the system information i3status # Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available) # finds out, if available)
bar { bar {

View File

@ -1,8 +1,6 @@
mode "system" {
# brightness control # brightness control
bindsym j exec --no-startup-id sudo brightnessctl set -q 5%- bindsym $mod+Ctrl+j exec sudo brightnessctl set -q 5%-
bindsym k exec --no-startup-id sudo brightnessctl set -q +5% bindsym $mod+Ctrl+k exec sudo brightnessctl set -q +5%
}
# Battery manager # Battery manager
exec_always --no-startup-id killall battmon; ~/.config/i3/scripts/battmon exec_always --no-startup-id killall battmon; battmon

34
.local/bin/dmenuexit Executable file
View File

@ -0,0 +1,34 @@
#!/bin/bash
ACTION="$(xargs -n 1 <<<"Lock Suspend Hibernate 'Exit i3' Shutdown Reboot" | dmenu -i -p "exitctl")"
[ -z "$ACTION" ] && exit 1
echo "INFO: Selected action $ACTION."
CONFIRMATION="$(xargs -n 1 <<<"No Yes" | dmenu -i -p "Are you sure you want to ${ACTION,,}?")"
{ [ -z "$CONFIRMATION" ] || [[ "$CONFIRMATION" != "Yes" ]]; } && exit 1
echo "INFO: Action confirmed."
case "${ACTION,,}" in
lock)
loginctl lock-session
;;
suspend)
systemctl suspend
;;
hibernate)
systemctl hibernate
;;
'exit i3')
i3-msg exit
;;
shutdown)
poweroff
;;
reboot)
reboot
;;
*)
echo "ERROR: Invalid action '${ACTION,,}'." 1>&2
;;
esac