#!/bin/sh # Managed by ansible (pi_kiosk role). # # kiosk-screen on|off|toggle|status - switch the kiosk's monitor on or off. # # "Off" is DPMS: X stops the HDMI signal and the monitor drops into standby. The # session, the browser and everything playing carry on. The MusicMouse backend runs # `kiosk-screen toggle` for the IR remote's power key (its config's screen: section); # it works over ssh as root too. # # .xinitrc turns DPMS off so the screen never blanks by itself. Forcing it off has to # turn DPMS on, so `on` turns it back off again - otherwise the screen would blank on # its own ten minutes after every switch-on. set -e export DISPLAY=:0 export XAUTHORITY=/home/{{ pi_kiosk_user }}/.Xauthority # With DPMS disabled `xset q` prints no monitor line at all, and the monitor is on. status() { if xset q | grep -q "Monitor is Off"; then echo off; else echo on; fi } screen_on() { xset dpms force on xset -dpms } screen_off() { xset +dpms xset dpms force off } case "$1" in on) screen_on ;; off) screen_off ;; toggle) if [ "$(status)" = off ]; then screen_on; else screen_off; fi ;; status) ;; *) echo "usage: $0 on|off|toggle|status" >&2 exit 2 ;; esac status