Support for blocking hibernation

This commit is contained in:
John Mertz 2022-11-21 18:56:50 -05:00
parent 4bdd817ae1
commit 14310c3c58
1 changed files with 22 additions and 17 deletions

View File

@ -1,7 +1,8 @@
#!/bin/bash
BLFILE="/home/jpm/.spool/idle.dim"
OPFILE="/home/jpm/.spool/active_outputs"
BLFILE="$HOME/.spool/idle.dim"
OPFILE="$HOME/.spool/active_outputs"
NOHIBERNATE="$HOME/.spool/hibernate_inhibitor
FADE_TIMEOUT=60 # one minute
DIM_TIMEOUT=120 # two minutes
@ -22,7 +23,7 @@ function usage()
unlock - (Run upon unlock) Mark as active again.
sleep - Disable displays, but continue background processes.
wake - Re-enable displays.
suspend - Hibernate.
hibernate - Hibernate.
help - This message."
exit
}
@ -42,7 +43,7 @@ elif [ $1 == "start" ]; then
resume "$0 unlock" \
timeout $DPMS_TIMEOUT "$0 sleep" \
resume "$0 wake" \
timeout $SUSPEND_TIMEOUT "$0 suspend"
timeout $SUSPEND_TIMEOUT "$0 hibernate"
elif [ $1 == "stop" ]; then
pkill swayidle
elif [ $1 == "fade" ]; then
@ -72,8 +73,12 @@ elif [ $1 == "sleep" ]; then
for i in `cat $OPFILE`; do swaymsg "output $i dpms off"; done
elif [ $1 == "wake" ]; then
/home/jpm/scripts/sway/displays.pl
elif [ $1 == "suspend" ]; then
elif [ $1 == "hibernate" ]; then
if [ -e $NOHIBERNATE ]; then
;;
else
sudo systemctl start hibernate.target
fi
else
echo "Invalid argument: $1"
usage