From f4d51d6e6556e452b19301537c06aecead6db641 Mon Sep 17 00:00:00 2001 From: Konstantin Koslowski Date: Wed, 11 May 2022 14:08:30 +0200 Subject: [PATCH] sway/bin: add suspend/suspend-hib --- bin/sway_exit | 3 +++ bin/sway_suspend | 16 ++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/bin/sway_exit b/bin/sway_exit index 42215e6..403b509 100755 --- a/bin/sway_exit +++ b/bin/sway_exit @@ -5,6 +5,8 @@ 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_SUSPEND_HIB=$IMG_BASE/scalable/apps/system-suspend.svg +CMD_SUSPEND_HIB="sway_suspend suspend-hib" IMG_RELOAD=$IMG_BASE/scalable/apps/system-software-update.svg CMD_RELOAD="swaymsg reload" IMG_EXIT=$IMG_BASE/scalable/apps/system-restart.svg @@ -12,6 +14,7 @@ CMD_EXIT="swaymsg exit" echo -e "img:$IMG_LOCK:text:$CMD_LOCK img:$IMG_SUSPEND:text:$CMD_SUSPEND +img:$IMG_SUSPEND_HIB:text:$CMD_SUSPEND_HIB img:$IMG_RELOAD:text:$CMD_RELOAD img:$IMG_EXIT:text:$CMD_EXIT" | \ wofi --dmenu --prompt "exit menu" | while read line; do diff --git a/bin/sway_suspend b/bin/sway_suspend index 414b37a..9bd4339 100755 --- a/bin/sway_suspend +++ b/bin/sway_suspend @@ -2,7 +2,6 @@ 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 @@ -23,11 +22,13 @@ function _suspend() { _check_inhibit $INHIBIT_FILE state=$(_state) force=${1:-0} + mode=${2:-suspend-then-hibernate} if [ $state -eq 1 -o $force -eq 1 ]; then + _log SUSPEND INFO starting. state: $state, force: $force, mode: $mode $MEDIA_APP stop - systemctl $MODE + systemctl $mode else - _log SUSPEND INFO aborting. state: $state, force: $force + _log SUSPEND INFO aborting. state: $state, force: $force, mode: $mode fi } @@ -39,13 +40,16 @@ case $1 in _set_inhibit $INHIBIT_FILE $2 ;; suspend-battery) - _suspend 0 + _suspend 0 suspend-then-hibernate ;; suspend) - _suspend 1 + _suspend 1 suspend + ;; + suspend-hib) + _suspend 1 suspend-then-hibernate ;; *) echo "invalid argument: \"$1\"" - echo "arguments: [inhibit [on|off]|suspend-battery|suspend]" + echo "arguments: [inhibit [on|off]|suspend-battery|suspend-only|suspend]" ;; esac