sway/bin: add suspend/suspend-hib
This commit is contained in:
parent
51e820c19e
commit
f4d51d6e65
2 changed files with 13 additions and 6 deletions
|
@ -5,6 +5,8 @@ IMG_LOCK=$IMG_BASE/scalable/apps/system-log-out.svg
|
||||||
CMD_LOCK="sway_lock lock"
|
CMD_LOCK="sway_lock lock"
|
||||||
IMG_SUSPEND=$IMG_BASE/scalable/apps/system-suspend.svg
|
IMG_SUSPEND=$IMG_BASE/scalable/apps/system-suspend.svg
|
||||||
CMD_SUSPEND="sway_suspend suspend"
|
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
|
IMG_RELOAD=$IMG_BASE/scalable/apps/system-software-update.svg
|
||||||
CMD_RELOAD="swaymsg reload"
|
CMD_RELOAD="swaymsg reload"
|
||||||
IMG_EXIT=$IMG_BASE/scalable/apps/system-restart.svg
|
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
|
echo -e "img:$IMG_LOCK:text:$CMD_LOCK
|
||||||
img:$IMG_SUSPEND:text:$CMD_SUSPEND
|
img:$IMG_SUSPEND:text:$CMD_SUSPEND
|
||||||
|
img:$IMG_SUSPEND_HIB:text:$CMD_SUSPEND_HIB
|
||||||
img:$IMG_RELOAD:text:$CMD_RELOAD
|
img:$IMG_RELOAD:text:$CMD_RELOAD
|
||||||
img:$IMG_EXIT:text:$CMD_EXIT" | \
|
img:$IMG_EXIT:text:$CMD_EXIT" | \
|
||||||
wofi --dmenu --prompt "exit menu" | while read line; do
|
wofi --dmenu --prompt "exit menu" | while read line; do
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
source $HOME/.config/sway/bin/sway_helpers
|
source $HOME/.config/sway/bin/sway_helpers
|
||||||
BAT_PATH=/sys/class/power_supply
|
BAT_PATH=/sys/class/power_supply
|
||||||
BAT=BAT0
|
BAT=BAT0
|
||||||
MODE=suspend-then-hibernate
|
|
||||||
MEDIA_APP=playerctl
|
MEDIA_APP=playerctl
|
||||||
INHIBIT_FILE=$HOME/.inhibit_suspend
|
INHIBIT_FILE=$HOME/.inhibit_suspend
|
||||||
|
|
||||||
|
@ -23,11 +22,13 @@ function _suspend() {
|
||||||
_check_inhibit $INHIBIT_FILE
|
_check_inhibit $INHIBIT_FILE
|
||||||
state=$(_state)
|
state=$(_state)
|
||||||
force=${1:-0}
|
force=${1:-0}
|
||||||
|
mode=${2:-suspend-then-hibernate}
|
||||||
if [ $state -eq 1 -o $force -eq 1 ]; then
|
if [ $state -eq 1 -o $force -eq 1 ]; then
|
||||||
|
_log SUSPEND INFO starting. state: $state, force: $force, mode: $mode
|
||||||
$MEDIA_APP stop
|
$MEDIA_APP stop
|
||||||
systemctl $MODE
|
systemctl $mode
|
||||||
else
|
else
|
||||||
_log SUSPEND INFO aborting. state: $state, force: $force
|
_log SUSPEND INFO aborting. state: $state, force: $force, mode: $mode
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,13 +40,16 @@ case $1 in
|
||||||
_set_inhibit $INHIBIT_FILE $2
|
_set_inhibit $INHIBIT_FILE $2
|
||||||
;;
|
;;
|
||||||
suspend-battery)
|
suspend-battery)
|
||||||
_suspend 0
|
_suspend 0 suspend-then-hibernate
|
||||||
;;
|
;;
|
||||||
suspend)
|
suspend)
|
||||||
_suspend 1
|
_suspend 1 suspend
|
||||||
|
;;
|
||||||
|
suspend-hib)
|
||||||
|
_suspend 1 suspend-then-hibernate
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "invalid argument: \"$1\""
|
echo "invalid argument: \"$1\""
|
||||||
echo "arguments: [inhibit [on|off]|suspend-battery|suspend]"
|
echo "arguments: [inhibit [on|off]|suspend-battery|suspend-only|suspend]"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in a new issue