Read the statement by Michael Teeuw here.
Setting up auto display off during the night.
-
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 mmThe 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 displayAs 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?
-
looks like
XDG_RUNTIME_DIRis unset, so you can check what value contains this variable in your user environment by executingecho $XDG_RUNTIME_DIRin the terminal and then changeWAYLAND_DISPLAY="wayland-1" wlr-randr --output HDMI-A-1 --offto
XDG_RUNTIME_DIR="value-from-above" WAYLAND_DISPLAY="wayland-1" wlr-randr --output HDMI-A-1 --off
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login