• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Setting up auto display off during the night.

Scheduled Pinned Locked Moved Unsolved Troubleshooting
2 Posts 2 Posters 409 Views 3 Watching
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.
  • G Offline
    greatm8nate
    last edited by Jul 4, 2024, 4:16 PM

    It seems that in recent months the commands used to control HDMI out on the Raspberry Pi have changed. Most guides I’ve found online do not work anymore.

    I just want to turn my display off at 8pm and turn it back on at 8am.
    So I set up a cron job;

    20 14 * * * pm2 stop mm 
    21 14 * * * WAYLAND_DISPLAY="wayland-1" wlr-randr --output HDMI-A-1 --off
    22 14 * * * WAYLAND_DISPLAY="wayland-1" wlr-randr --output HDMI-A-1 --on
    23 14 * * * wlr-randr --output HDMI-A-1 transform 270
    24 14 * * * pm2 start mm
    

    The timing is one minute apart for testing.
    Line 1 stops magic mirror.
    Line 2 should turn the display off.
    Line 3 turns it back on.
    Line 4 correct the screen orientation to portrait (it is not saved).
    Line 5 restarts the software.

    That command on line 2 works when manually typed into the terminal, but the cron job cannot execute it for some reason. Here is the error log I collected for lines 2-4;

    error: XDG_RUNTIME_DIR is invalid or not set in the environment.
    failed to connect to display
    

    As far as I have researched, the cron job is not in the same environment as me (the user), so it cannot execute this command. How to I make the cron job write as if I am typing the command into the terminal?

    K 1 Reply Last reply Jul 4, 2024, 8:09 PM Reply Quote 0
    • K Offline
      karsten13 @greatm8nate
      last edited by Jul 4, 2024, 8:09 PM

      @greatm8nate

      looks like XDG_RUNTIME_DIR is unset, so you can check what value contains this variable in your user environment by executing echo $XDG_RUNTIME_DIR in the terminal and then change

      WAYLAND_DISPLAY="wayland-1" wlr-randr --output HDMI-A-1 --off
      

      to

      XDG_RUNTIME_DIR="value-from-above" WAYLAND_DISPLAY="wayland-1" wlr-randr --output HDMI-A-1 --off
      
      1 Reply Last reply Reply Quote 0
      • 1 / 1
      1 / 1
      • First post
        1/2
        Last post
      Enjoying MagicMirror? Please consider a donation!
      MagicMirror created by Michael Teeuw.
      Forum managed by Sam, technical setup by Karsten.
      This forum is using NodeBB as its core | Contributors
      Contact | Privacy Policy