sway: update sway_exit script with icons, adapt sway_suspend, update config accordingly

This commit is contained in:
Konstantin Koslowski 2022-04-21 01:42:42 +02:00
parent 0271bfb5d9
commit ac387d4c1b
3 changed files with 28 additions and 9 deletions

View file

@ -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