2021-01-18 02:54:21 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
BLFILE="/home/jpm/.config/blc.last"
|
|
|
|
OPFILE="/home/jpm/.config/active_outputs"
|
|
|
|
|
|
|
|
if [ -z $1 ]; then
|
2022-04-19 04:26:56 +00:00
|
|
|
echo "Missing argument: start, warn, lock, unlock, sleep, wake, or resume"
|
2021-01-18 02:54:21 +00:00
|
|
|
elif [ $1 == "start" ]; then
|
|
|
|
swayidle -w timeout 270 "/home/jpm/scripts/sway/idle.sh warn" \
|
|
|
|
resume "/home/jpm/scripts/sway/idle.sh resume" \
|
|
|
|
timeout 300 "/home/jpm/scripts/sway/idle.sh sleep" \
|
|
|
|
resume "/home/jpm/scripts/sway/idle.sh wake" \
|
2022-04-19 04:26:56 +00:00
|
|
|
before-sleep "/usr/bin/swaylock -c 000000"
|
2021-01-18 02:54:21 +00:00
|
|
|
elif [ $1 == "warn" ]; then
|
|
|
|
# Store current brightness
|
|
|
|
echo $(/home/jpm/scripts/thinkpad/blc.pl %) > $BLFILE
|
|
|
|
# Dim display
|
|
|
|
/home/jpm/scripts/thinkpad/blc.pl = 1
|
|
|
|
# Warning notifications
|
|
|
|
/home/jpm/scripts/sway/idlecountdown.sh
|
2022-04-19 04:26:56 +00:00
|
|
|
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`
|
2021-01-18 02:54:21 +00:00
|
|
|
elif [ $1 == "sleep" ]; then
|
|
|
|
# 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
|
2022-04-19 04:26:56 +00:00
|
|
|
#for i in `cat $OPFILE`; do swaymsg "output $i dpms off"; done
|
2021-01-18 02:54:21 +00:00
|
|
|
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
|
|
|
|
#for i in `cat $OPFILE`; do swaymsg "output $i dpms on"; done
|
|
|
|
# Lock screen
|
2022-04-19 04:26:56 +00:00
|
|
|
swaylock -c 000000
|
2021-01-18 02:54:21 +00:00
|
|
|
# Restore brightness level
|
|
|
|
/home/jpm/scripts/thinkpad/blc.pl = $(cat $BLFILE)
|
|
|
|
elif [ $1 == "resume" ]; then
|
|
|
|
# Kill warning
|
2022-04-19 04:26:56 +00:00
|
|
|
for i in `pkill idlecountdown`; do kill $i; done
|
|
|
|
/home/jpm/scripts/thinkpad/blc.pl = $(cat $BLFILE)
|
2021-01-18 02:54:21 +00:00
|
|
|
else
|
2022-04-19 04:26:56 +00:00
|
|
|
echo "Invalid argument: start, warn, lock, unlock, sleep, wake, or resume"
|
2021-01-18 02:54:21 +00:00
|
|
|
fi
|