Search code examples
c#linux.net-coreraspberry-piraspbian

Prevent screensaver depending on activity


I have an .NET Core app displaying data using a raspberry PI (Raspberry PI OS/Raspbian). I'd like to prevent raspberry's screensaver (or sleep mode) only when there's something to display. Which command can I send ? What mecanism can I use ?


Solution

  • I found how to do so :

    • First, I permanently deactivate screen-saver with autostart script and commands :

      @xset s off

      @xset -dpms

    • Next, I only "play" with hdmi activation when I need it:

      - `tvservice -p` to activate HDMI display
      - `tvservice -o` to deactivate HDMI display
      

    To send command, I use this :

    Process.Start(new ProcessStartInfo { FileName = "/usr/bin/bash", Arguments = "-c \" COMMAND_TO_SEND \""}).WaitForExit();