sway/bin: add suspend/suspend-hib
This commit is contained in:
parent
51e820c19e
commit
f4d51d6e65
2 changed files with 13 additions and 6 deletions
bin
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue