improve idle behaviour
This commit is contained in:
parent
03bb1b1695
commit
d90eaeed5c
104
sway/idle.sh
104
sway/idle.sh
|
@ -1,50 +1,76 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
BLFILE="/home/jpm/.config/blc.last"
|
BLFILE="/home/jpm/.spool/idle.dim"
|
||||||
OPFILE="/home/jpm/.config/active_outputs"
|
OPFILE="/home/jpm/.spool/active_outputs"
|
||||||
|
|
||||||
|
FADE_TIMEOUT=60 # one minute
|
||||||
|
DIM_TIMEOUT=120 # two minutes
|
||||||
|
LOCK_TIMEOUT=300 # five minutes
|
||||||
|
DPMS_TIMEOUT=600 # ten minutes
|
||||||
|
SUSPEND_TIMEOUT=3600 # one hour
|
||||||
|
|
||||||
|
function usage()
|
||||||
|
{
|
||||||
|
echo "usage: $0 <option>
|
||||||
|
start - Initialize 'swayidle' script. This should be declared in Sway config.
|
||||||
|
stop - Kill 'swayidle' script. Consider idle-inhibitor instead.
|
||||||
|
fade - First idle action. Fades all windows to show background.
|
||||||
|
unfade - Restore opacity for faded windows.
|
||||||
|
dim - Reduce display brightness to minimum.
|
||||||
|
undim - Restore brightness to level prior to 'dim'.
|
||||||
|
lock - Mark as inactive and start 'swaylock'.
|
||||||
|
unlock - (Run upon unlock) Mark as active again.
|
||||||
|
sleep - Disable displays, but continue background processes.
|
||||||
|
wake - Re-enable displays.
|
||||||
|
suspend - Hibernate.
|
||||||
|
help - This message."
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
if [ -z $1 ]; then
|
if [ -z $1 ]; then
|
||||||
echo "Missing argument: start, warn, lock, unlock, sleep, wake, or resume"
|
echo "Missing argument"
|
||||||
|
usage
|
||||||
|
elif [ $1 == "-h" ] || [ $1 == "--help" ] || [ $1 == "help" ]; then
|
||||||
|
usage
|
||||||
elif [ $1 == "start" ]; then
|
elif [ $1 == "start" ]; then
|
||||||
swayidle -w timeout 270 "/home/jpm/scripts/sway/idle.sh warn" \
|
swayidle -w \
|
||||||
resume "/home/jpm/scripts/sway/idle.sh resume" \
|
timeout $FADE_TIMEOUT "$0 fade" \
|
||||||
timeout 300 "/home/jpm/scripts/sway/idle.sh sleep" \
|
resume "$0 unfade" \
|
||||||
resume "/home/jpm/scripts/sway/idle.sh wake" \
|
timeout $DIM_TIMEOUT "$0 dim" \
|
||||||
before-sleep "/usr/bin/swaylock -c 000000"
|
resume "$0 undim" \
|
||||||
elif [ $1 == "warn" ]; then
|
timeout $LOCK_TIMEOUT "$0 lock" \
|
||||||
# Store current brightness
|
resume "$0 unlock" \
|
||||||
echo $(/home/jpm/scripts/thinkpad/blc.pl %) > $BLFILE
|
timeout $DPMS_TIMEOUT "$0 sleep" \
|
||||||
# Dim display
|
resume "$0 wake" \
|
||||||
/home/jpm/scripts/thinkpad/blc.pl = 1
|
timeout $SUSPEND_TIMEOUT "$0 suspend"
|
||||||
# Warning notifications
|
elif [ $1 == "stop" ]; then
|
||||||
/home/jpm/scripts/sway/idlecountdown.sh
|
pkill swayidle
|
||||||
|
elif [ $1 == "fade" ]; then
|
||||||
|
$HOME/scripts/sway/fade.pl start
|
||||||
|
elif [ $1 == "unfade" ]; then
|
||||||
|
$HOME/scripts/sway/fade.pl stop
|
||||||
|
elif [ $1 == "dim" ]; then
|
||||||
|
echo $($HOME/scripts/thinkpad/blc.pl %) > $BLFILE
|
||||||
|
$HOME/scripts/thinkpad/blc.pl = 1 &>-
|
||||||
|
elif [ $1 == "undim" ]; then
|
||||||
|
$HOME/scripts/thinkpad/blc.pl = `cat $BLFILE` &>-
|
||||||
elif [ $1 == "lock" ]; then
|
elif [ $1 == "lock" ]; then
|
||||||
echo $(/home/jpm/scripts/thinkpad/blc.pl %) > $BLFILE
|
|
||||||
/home/jpm/scripts/thinkpad/blc.pl = 1
|
|
||||||
ssh jpm@john.me.tz -i /home/jpm/.ssh/no_pass -t \
|
|
||||||
'screen -S irssi -X stuff "/nick jpmAFK^M"'
|
|
||||||
elif [ $1 == "unlock" ]; then
|
|
||||||
/home/jpm/scripts/thinkpad/blc.pl = `cat $BLFILE`
|
|
||||||
elif [ $1 == "sleep" ]; then
|
|
||||||
# Change nick to AFK
|
# Change nick to AFK
|
||||||
ssh jpm@john.me.tz -i /home/jpm/.ssh/no_pass -t \
|
#ssh jpm@john.me.tz -i /home/jpm/.ssh/no_pass -t \
|
||||||
'screen -S irssi -X stuff "/nick jpmAFK^M"'
|
#'screen -S irssi -X stuff "/nick jpmAFK^M"'
|
||||||
# Turn off monitor
|
:
|
||||||
#for i in `cat $OPFILE`; do swaymsg "output $i dpms off"; done
|
elif [ $1 == "unlock" ]; then
|
||||||
|
# Change nick to AFK
|
||||||
|
#ssh jpm@john.me.tz -i /home/jpm/.ssh/no_pass -t \
|
||||||
|
#'screen -S irssi -X stuff "/nick jpm^M"'
|
||||||
|
:
|
||||||
|
elif [ $1 == "sleep" ]; then
|
||||||
|
for i in `cat $OPFILE`; do swaymsg "output $i dpms off"; done
|
||||||
elif [ $1 == "wake" ]; then
|
elif [ $1 == "wake" ]; then
|
||||||
# Kill additional counters that might have been started
|
|
||||||
/home/jpm/scripts/sway/idle.sh resume
|
|
||||||
# Restore output(s)
|
|
||||||
/home/jpm/scripts/sway/displays.pl
|
/home/jpm/scripts/sway/displays.pl
|
||||||
#for i in `cat $OPFILE`; do swaymsg "output $i dpms on"; done
|
elif [ $1 == "suspend" ]; then
|
||||||
# Lock screen
|
sudo systemctl start hibernate.target
|
||||||
swaylock -c 000000
|
|
||||||
# Restore brightness level
|
|
||||||
/home/jpm/scripts/thinkpad/blc.pl = $(cat $BLFILE)
|
|
||||||
elif [ $1 == "resume" ]; then
|
|
||||||
# Kill warning
|
|
||||||
for i in `pkill idlecountdown`; do kill $i; done
|
|
||||||
/home/jpm/scripts/thinkpad/blc.pl = $(cat $BLFILE)
|
|
||||||
else
|
else
|
||||||
echo "Invalid argument: start, warn, lock, unlock, sleep, wake, or resume"
|
echo "Invalid argument: $1"
|
||||||
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue