2 # Script to control and query a connected screen
3 # For infoscreen purposes
4 # Tries to use cec-client and falls back to DPMS
5 # Usage: ./screencontrol.sh [query | on | off]
12 if [ "${1}" == "query" ]; then
13 if status
=$
(echo "pow 0" | cec-client
-s -d 1); then
14 if [[ ${status} =~
(power status
: on
) ]]; then
20 if status
=$
(xset q
); then
21 if [[ ${status} =~
(Monitor is Off
) ]]; then
27 echo "Unable to determine status of screen"
31 elif [ "${1}" == "on" ]; then
32 if echo "on 0" | cec-client
-s -d 1 >/dev
/null
; then
36 echo "Screen turned on (CEC)"
38 if xset dpms force on
; then
42 echo "Screen turned on (DPMS)"
44 echo "Unable to turn screen on"
48 elif [ "${1}" == "off" ]; then
49 if echo "standby 0" | cec-client
-s -d 1 >/dev
/null
; then
50 echo "Screen turned off (CEC)"
52 if xset dpms force off
; then
53 echo "Screen turned off (DPMS)"
55 echo "Unable to turn screen off"
59 echo "Error: Unknown command"