Turn Raspberry screen on or off¶
Control the screen power state of a Raspberry Pi using the vcgencmd
command or wlr-randr
for Wayland.
Wayland¶
Try it out before by running wlr-randr --output HDMI-A-1 --off
to turn off the screen and wlr-randr --output HDMI-A-1 --on
to turn it back on.
shell:
switch:
- platform: shell
name: "Screen"
id: screen
command_on: "wlr-randr --output HDMI-A-1 --on"
command_off: "wlr-randr --output HDMI-A-1 --off"
command_state: |-
if wlr-randr --output HDMI-A-1 | grep -q "Enabled: yes"; then
echo true
else
echo false
fi
X11¶
Try it out before by running vcgencmd display_power 0
to turn off the screen and vcgencmd display_power 1
to turn it back on.
Be sure to have
dtoverlay=vc4-fkms-v3d
activated.