#!/bin/bash # Detect on/off state of monitor, and toggle it to the other. export DISPLAY=:0.0 SCREENSTATE=$(xset dpms q | grep Monitor | sed 's/\ //g') case "$SCREENSTATE" in "MonitorisOff" ) # Monitor is off, turn it on and reset the DPMS settings esdplay ~/sounds/screen_on.wav xset dpms force on xset s reset xset s off xset s noblank ;; "MonitorisOn" ) # Since Monitor is currently on according to DPMS, turn it off. xset dpms force off ;; esac