Switch musicdolphin's screen from the IR remote's power key
pi_kiosk installs kiosk-screen on|off|toggle|status, which switches the monitor via DPMS on the kiosk's X display (the Dell P2419H has no HDMI-CEC). Turning it back on also turns DPMS off again, as .xinitrc does, so the screen never blanks by itself. musicdolphin's backend config runs `kiosk-screen toggle` for the power key (the new screen: section, MusicMouse 2d0caeb). config.yml is install-once, so the running host is changed by hand the same way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
44
roles/pi_kiosk/templates/kiosk-screen.j2
Normal file
44
roles/pi_kiosk/templates/kiosk-screen.j2
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/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
|
||||
Reference in New Issue
Block a user