123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
-
- version=1.0
- if [[ "$#" -ge 2 ]]; then
- echo "Usage: $0 {-v, --version | -h --help}"
- exit 2
- elif [[ "$#" -eq 1 ]]; then
- case $1 in
- -v | --version)
- echo "$0 - Version $version"
- exit 0;;
- -h | --help)
- echo "This is a simple program that toggles/untoggles the screensaver and power management, useful to watch videos fullscreen."
- echo "- v, --version Display current version"
- echo "-h, --help Display this message"
- exit 0;;
- *)
- echo "Usage: $0 {-v, --version | -h, --help}"
- exit 2;;
- esac
- fi
- if [ ! -f /bin/notify-send-improved ]; then
- echo "Notify-send-improved not present."
- echo "Please install it."
- exit 2
- fi
- if [ ! -f "/tmp/i3-screensaver-toggle.dat" ]; then
- notification_id="0"
- if xset q | grep "DPMS is Disabled" > /dev/null; then
- screensaver_mode="OFF"
- else
- screensaver_mode="ON"
- fi
- else
- screensaver_mode=`cat /tmp/i3-screensaver-toggle.dat | cut -d'.' -f 1`
- notification_id=`cat /tmp/i3-screensaver-toggle.dat | cut -d'.' -f 2`
- fi
- if [ $screensaver_mode = "ON" ]; then
- screensaver_mode="OFF"
- xset s off
- xset -dpms
- if [ $notification_id = "0" ]; then
- notification_id=$(notify-send-improved "Screensaver Toggle" --print-id -t 1000 "Screensaver/PowerManagement off" | tee /dev/tty)
- else
- notify-send-improved "Screensaver Toggle" --print-id --replace=$notification_id -t 1000 "Screensaver/PowerManagement off"
- fi
- else
- screensaver_mode="ON"
- xset s on
- xset +dpms
- if [ $notification_id = "0" ]; then
- notification_id=$(notify-send-improved "Screensaver Toggle" --print-id -t 1000 "Screensaver/PowerManagement on" | tee /dev/tty)
- else
- notify-send-improved "Screensaver Toggle" --print-id --replace=$notification_id -t 1000 "Screensaver/PowerManagement on"
- fi
- fi
- echo "$screensaver_mode.$notification_id" > /tmp/i3-screensaver-toggle.dat
|