Skip to content

Commit

Permalink
third display_power option to use wlr-randr i.e. for RPi5 wayland des…
Browse files Browse the repository at this point in the history
…ktop
  • Loading branch information
paddywwoof committed Oct 13, 2024
1 parent 0a50dce commit 0e2c8eb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/picframe/config/configuration_example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ viewer:
display_y: 0 # offset from top of screen (can be negative)
display_w: null # width of display surface (null->None will use max returned by hardware)
display_h: null # height of display surface
display_power: 0 # default=0. choices={0, 1}, 0 will use legacy `vcgencmd` and 1 will use `xset` to blank the display
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
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.
use_sdl2: False # default=True. pysdl2 can use display without xserver, it should be installed as a dependency of pi3d
# but might need `sudo apt install libsdl2-dev` if picframe gives errors about missing sdl2
Expand Down
8 changes: 8 additions & 0 deletions src/picframe/viewer_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ def display_is_on(self, on_off):
except Exception as e:
self.__logger.debug("Display ON/OFF is xset via dpms, but an error occured")
self.__logger.debug("Cause: %s", e)
elif self.__display_power == 2:
try: # try wlr-randr for RPi5 with wayland desktop
wlr_randr_cmd = ["wlr-randr", "--output", "HDMI-A-1"]
wlr_randr_cmd.append('--on' if on_off else '--off')
subprocess.call(wlr_randr_cmd)
except Exception as e:
self.__logger.debug("Display ON/OFF is wlr-randr, but an error occured")
self.__logger.debug("Cause: %s", e)
else:
self.__logger.warning("Unsupported setting for display_power=%d.", self.__display_power)

Expand Down

2 comments on commit 0e2c8eb

@CaCu15
Copy link

@CaCu15 CaCu15 commented on 0e2c8eb Oct 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paddywwoof
It's great to see you're working on this topic! Last weekend I tried to update my picframe installation to a bookworm / wayland based setup and discovered exactly this problem.
My current solution was basically as described in #386 but with triggering of the start / stop by SSH. But it would be great to have the wlr-randr calls integrated into picframe itself.

One comment to your commit: So far you only changed the method "display_is_on(self, on_off)". Don't we need to update the method display_is_on(self): as well to consider the third option (self.__display_power== 2). In my current workaround script I'm searching for the string "enabled: yes" in the wlr-randr output, thus something like this could work:

        elif self.__display_power == 2:
            try:  # try wlr_randr 
                output = subprocess.check_output(["wlr-andr"]). # assuming the WAYLAND_DISPLAY env is set correctly
                if output.find(b'Enabled: yes') != -1:
                    return True
                else:
                    return False

P.S. I will be happy to support testing of this new feature!

@paddywwoof
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a very good point, and neat solution.Grateful for offer of testing too!

Please sign in to comment.