RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    Run custom script on screensaver start and end

    Scheduled Pinned Locked Moved Help and Support
    screen saverscreensaverscreensavers
    2 Posts 2 Posters 1.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • F
      fuzznuzzbit
      last edited by

      Hi,
      I am interested in having a custom script launch when the screensaver starts and end. I'm not a developer, but I can probably figure out Python enough to turn a GPIO pin turn off and on to trigger a high voltage relay. I'd like to turn off my monitor and translite when the screensaver kicks in, then turn them back on when the screensaver is done.
      I could see other folks wanting to do something custom like gracefully shutdown their RetroPie, or really anything.
      Is there a configuration that would allow this - screensaver run a custom script at startup and end? I'm asking here before I add it as an idea for the developers.
      Thanks

      1 Reply Last reply Reply Quote 0
      • cyperghostC
        cyperghost
        last edited by cyperghost

        This would be possible if you check presence of OMXPlayer process. It's not an elegant method but it might work. But keep in mind you will loose opportunity to play video snapshots in gamelist

        So the better way would be an implementation into the C++ code of ES itslef.

        PSEUDOCODE

        #!/bin/bash
        # Run this script with root user or sudo command
        # Initiate GPIO x ouput
        #   Exports pin to userspace
        echo x > /sys/class/gpio/export                  
        
        # Sets pin x as an output
        echo out > /sys/class/gpio/gpiox/direction
        
            while true
            do
                # Slow down the whole thing a bit
                sleep 5
                # Suggest running oxmplayer instance
                omxpid=$(pgrep omxplayer)
                # Set GPIO x high > switch off screen
                [[ -n $omxpid ]] && echo "1" > /sys/class/gpio/gpiox/value
                # Set GPIO x low > switch on screen
                [[ -z $omxpid ]] && echo "0" > /sys/class/gpio/gpiox/value
            done
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post

        Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

        Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.