diff --git a/bin/sway_exit b/bin/sway_exit index 04b5cfc..42215e6 100755 --- a/bin/sway_exit +++ b/bin/sway_exit @@ -1,4 +1,20 @@ #!/bin/bash export PATH=$PATH:$HOME/.config/sway/bin -bash -c "$(echo -e 'sway_lock lock\nsystemctl suspend\nswaymsg reload\nswaymsg exit' | \ - wofi --dmenu --prompt 'exit menu')" +IMG_BASE=$HOME/.local/share/icons/Tela-circle-dark +IMG_LOCK=$IMG_BASE/scalable/apps/system-log-out.svg +CMD_LOCK="sway_lock lock" +IMG_SUSPEND=$IMG_BASE/scalable/apps/system-suspend.svg +CMD_SUSPEND="sway_suspend suspend" +IMG_RELOAD=$IMG_BASE/scalable/apps/system-software-update.svg +CMD_RELOAD="swaymsg reload" +IMG_EXIT=$IMG_BASE/scalable/apps/system-restart.svg +CMD_EXIT="swaymsg exit" + +echo -e "img:$IMG_LOCK:text:$CMD_LOCK +img:$IMG_SUSPEND:text:$CMD_SUSPEND +img:$IMG_RELOAD:text:$CMD_RELOAD +img:$IMG_EXIT:text:$CMD_EXIT" | \ + wofi --dmenu --prompt "exit menu" | while read line; do + bash -c "$line" +done + diff --git a/bin/sway_suspend b/bin/sway_suspend index ece6b90..414b37a 100755 --- a/bin/sway_suspend +++ b/bin/sway_suspend @@ -3,13 +3,15 @@ source $HOME/.config/sway/bin/sway_helpers BAT_PATH=/sys/class/power_supply BAT=BAT0 MODE=suspend-then-hibernate +MEDIA_APP=playerctl INHIBIT_FILE=$HOME/.inhibit_suspend ## helpers -# 0: charging -# 1: discharging/unknown +# 1: discharging +# 0: charging/full function _state() { f=$BAT_PATH/$BAT/status + # default to discharging when status file not found s=1 if [ -e $f ]; then s=$(grep -c Discharging $f) @@ -22,6 +24,7 @@ function _suspend() { state=$(_state) force=${1:-0} if [ $state -eq 1 -o $force -eq 1 ]; then + $MEDIA_APP stop systemctl $MODE else _log SUSPEND INFO aborting. state: $state, force: $force @@ -35,14 +38,14 @@ case $1 in i*) _set_inhibit $INHIBIT_FILE $2 ;; - suspend) + suspend-battery) _suspend 0 ;; - force) + suspend) _suspend 1 ;; *) echo "invalid argument: \"$1\"" - echo "arguments: [inhibit [on|off]|suspend|force]" + echo "arguments: [inhibit [on|off]|suspend-battery|suspend]" ;; esac diff --git a/config b/config index 1eef72a..55f6ac0 100644 --- a/config +++ b/config @@ -70,8 +70,8 @@ exec swayidle -w \ timeout 1800 '$lock_cmd off' \ resume '$lock_cmd on' \ timeout 2700 '$lock_cmd lockonly' \ - timeout 3600 '$suspend_cmd suspend' \ - timeout 7200 '$suspend_cmd force' \ + timeout 3600 '$suspend_cmd suspend-battery' \ + timeout 7200 '$suspend_cmd suspend' \ before-sleep '$lock_cmd lock' bindsym $mod+Ctrl+Escape exec '$lock_cmd lock'