Skip to content

Commit 0e2c8eb

Browse files
committed
third display_power option to use wlr-randr i.e. for RPi5 wayland desktop
1 parent 0a50dce commit 0e2c8eb

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/picframe/config/configuration_example.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ viewer:
2222
display_y: 0 # offset from top of screen (can be negative)
2323
display_w: null # width of display surface (null->None will use max returned by hardware)
2424
display_h: null # height of display surface
25-
display_power: 0 # default=0. choices={0, 1}, 0 will use legacy `vcgencmd` and 1 will use `xset` to blank the display
25+
display_power: 0 # default=0. choices={0, 1, 2}, 0 will use legacy `vcgencmd`, 1 will use `xset`, 2 will use 'wlr-randr' to blank the display
2626
use_glx: False # default=False. Set to True on linux with xserver running. NB use_sdl2 might need to be False for this to work.
2727
use_sdl2: False # default=True. pysdl2 can use display without xserver, it should be installed as a dependency of pi3d
2828
# but might need `sudo apt install libsdl2-dev` if picframe gives errors about missing sdl2

src/picframe/viewer_display.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,14 @@ def display_is_on(self, on_off):
154154
except Exception as e:
155155
self.__logger.debug("Display ON/OFF is xset via dpms, but an error occured")
156156
self.__logger.debug("Cause: %s", e)
157+
elif self.__display_power == 2:
158+
try: # try wlr-randr for RPi5 with wayland desktop
159+
wlr_randr_cmd = ["wlr-randr", "--output", "HDMI-A-1"]
160+
wlr_randr_cmd.append('--on' if on_off else '--off')
161+
subprocess.call(wlr_randr_cmd)
162+
except Exception as e:
163+
self.__logger.debug("Display ON/OFF is wlr-randr, but an error occured")
164+
self.__logger.debug("Cause: %s", e)
157165
else:
158166
self.__logger.warning("Unsupported setting for display_power=%d.", self.__display_power)
159167

0 commit comments

Comments
 (0)