scripts/sway/swayidle.sh

33 líneas
1.1 KiB
Bash
Archivo Ejecutable

#!/bin/bash
BLFILE="/tmp/blc"
if [ -z $1 ]; then
echo "Missing argument: swayidlerun, swayidlewarn, swayidlesleep or swayidlewake"
elif [ $1 == "swayidlerun" ]; then
swayidle timeout 270 "/home/jpm/scripts/swayidle.sh swayidlewarn" before-sleep "/home/jpm/scripts/swayidle.sh swayidlesleep" resume "/home/jpm/scripts/swayidle.sh swayidlewake"
elif [ $1 == "swayidlewarn" ]; then
# 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
elif [ $1 == "swayidlesleep" ]; 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
swaymsg 'swaymsg "output * dpms off"'
# Lock screen
swaylock -c 323232
elif [ $1 == "swayidlewake" ]; then
# 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)
else
echo "Invalid argument: run, sleep or wake"
fi