I recently received an email from a reader telling me that there was a problem.
The long-serving command vcgencmd display_power 1/0
wouldn’t work with the latest Raspberry Pi operating system update.
I have written a post here to explain several ways to automatically turn your Raspberry Pi digital picture frame on and off at fixed times or simply with a Terminal command.
Tested with Raspberry Pi OS Bookworm on a Raspberry Pi 4 (Nov 2024).
Death by consensus
It turns out that the vcgencmd
command had been retired and moved to the graveyard of commands that we used a lot but, for some inexplicable reason, had to die a cruel death because some code maintainers decided it was time.
In Nov 2024, the Raspberry Pi Foundation announced the move to a new windowing technology called Wayland and a compositor called labwc.
This changed all the commands, but at least it is working now.
A new hope
Provided you are running a Raspberry Pi 2/3/4/5 with the OS Bookworm, you can use the following Terminal command to turn your connected HDMI monitor (the left output of the two) off:
wlr-randr --output HDMI-A-1 --off
To turn it on, type:
So in the case of a 4K display, you would write (change the resolution to your monitor):
wlr-randr --output HDMI-A-1 --on --mode 3840x2160
Here is what the Python script for turning the monitor off would look like:
#!/usr/bin/python3
# coding: utf8 #
import subprocess # for command execution
def turn_off_monitor():
try:
subprocess.call("wlr-randr --output HDMI-A-1 --off", shell=True)
print("Monitor HDMI-A-1 turned off successfully.")
except Exception as e:
print(f"An error occurred: {e}")
turn_off_monitor()
And for turning it on:
#!/usr/bin/python3
# coding: utf8 #
import subprocess # for command execution
def turn_on_monitor():
try:
subprocess.call("wlr-randr --output HDMI-A-1 --on --mode 3840x2160", shell=True)
print("Monitor HDMI-A-1 turned on successfully.")
except Exception as e:
print(f"An error occurred: {e}")
turn_on_monitor()
The missing display status
The vcgencmd
returned a “0” or “1” depending on the monitor being off or on.
With Wayland type
wlr-randr
and it will return a value like
Enabled: yes (or no)
depending on the display status.
Was this article helpful?
Thank you for your support and motivation.
Related Articles
- Celebrate birthdays and anniversaries with auto-themed photos on your digital frame
- Why Raspberry Pi Connect is the perfect screen sharing and remote shell tool for your digital photo frame maintenance
- Why the 2.4 GHz WiFi band is faster and more stable for your digital picture frame than 5 GHz
- How to automatically remove duplicate images from your Pictures folder (2024 Edition)