scripts/sway/swayidle.sh

37 lines
1.3 KiB
Bash
Raw Normal View History

2020-09-11 15:00:39 +00:00
#!/bin/bash
BLFILE="/tmp/blc"
if [ -z $1 ]; then
2020-11-23 09:35:26 +00:00
echo "Missing argument: swayidlerun, swayidlewarn, swayidlesleep or" \
" swayidlewake"
2020-09-11 15:00:39 +00:00
elif [ $1 == "swayidlerun" ]; then
2020-11-23 09:35:26 +00:00
swayidle timeout 270 "/home/jpm/scripts/swayidle.sh swayidlewarn" \
before-sleep "/home/jpm/scripts/swayidle.sh swayidlesleep" \
resume "/home/jpm/scripts/swayidle.sh swayidlewake"
2020-09-11 15:00:39 +00:00
elif [ $1 == "swayidlewarn" ]; then
2020-11-23 09:35:26 +00:00
# Store current brightness
echo $(/home/jpm/bin/blc.pl %) > $BLFILE
# Dim display
/home/jpm/bin/blc.pl = 1
# Warning notifications
/home/jpm/scripts/swayidlecountdown.sh
2020-09-11 15:00:39 +00:00
elif [ $1 == "swayidlesleep" ]; then
2020-11-23 09:35:26 +00:00
# Change nick to AFK
ssh jpm@john.me.tz -i /home/jpm/.ssh/no_pass -t \
'screen -S irssi -X stuff "/nick jpmAFK^M"'
# Turn off monitor
swaymsg 'swaymsg "output * dpms off"'
# Lock screen
swaylock -c 323232
2020-09-11 15:00:39 +00:00
elif [ $1 == "swayidlewake" ]; then
2020-11-23 09:35:26 +00:00
# Kill sleep if running
# Turn on monitor
swaymsg 'swaymsg "output * dpms on"'
# Restore brightness level
kill `pgrep swayidlecountdo`
/home/jpm/bin/blc.pl = $(cat /tmp/blc)
2020-09-11 15:00:39 +00:00
else
2020-11-23 09:35:26 +00:00
echo "Invalid argument: run, sleep or wake"
2020-09-11 15:00:39 +00:00
fi