Change code of Turn monitor on/off
Fredi009sg opened this issue · 13 comments
Description
Since a while raspi core were modified and has removed "vcgencmd display_power" its not anymore possible to turn on and off the monitor. Which works for me as an alternative is the following code "xrandr -d :0 --output HDMI-1 --off" for turn monitor off and "xrandr -d :0 --output HDMI-1 --auto" for turn monitor on. Is there any change that you adjust the code ?
Changelog
No response
Requirements
No response
Additional info
No response
This explains why my display hasn't been shutting off. Your suggestion did not work for me.
Hi! Thanks for reporting this issue.
I'm not an owner of a RPi, so I cannot test those commands myself, but since there're many users of RC, we cannot take this change lightly. However, you could set you own config.js to point into the right direction, please check our FAQ and some older issues (#284 (comment)) to understand better my point.
Hope you stay well!
Would appreciate as well!
Hi everyone,
I finally understand why my home automation couldn't turn off my mirror anymore... Thanks @Fredi009sg !
Moreover, your workaround proposal just work fine to turn OFF and ON the HDMI output.
(my setup: rPI3B / Debian Bulleye 64bit Full / Automated install script by sdetweil / MMM-Remote quick install)
Unfortunately we lose the function Monitor STATUS... I did some experiments with the command xrandr -d :0 --prop
but I'm not a developer and I'm at the limit of my tweaking skills.
I understand that modification should not be made without careful consideration but maybe it would be possible to support several display managers... The default would remain vcgencmd but, with some configuration, we could support xrandr, tvservice, cec-client, etc... depending on the platforms.
What do you think of this proposal ?
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
@Killator there're certain modifications that can be made through the config file, no development needed. You can take a look into the Remote Control Wiki to understand better what I'm trying to point.
If any of you are up to, we can modify the Wiki and let there established diferent working methods for every RPi and Linux instance, so that anyone can check which commands works in their usecase.
Hi @ezeholz,
Thanks for your response ! It works perfectly with the customCommand feature !
config: {
customCommand: {
monitorOnCommand: 'xrandr -d :0 --output HDMI-1 --auto',
monitorOffCommand: 'xrandr -d :0 --output HDMI-1 --off'
}
}
It would be perfect with the monitorStatusCommand to trace the information in my home automation.
I've tried several times but can't find anything that works with xrandr...
Have you another brillant suggestion ? ;)
Hey @Killator!
Glad that worked out perfectly.
About the status, I'm not an expert in this area, but I'll let you a command that I grab from Bard. I'm not sure if it's gonna work, but let me know if you test it or find any other solution.
monitorStatusCommand: 'grep -q "connected" $(xrandr --query | grep -E "HDMI-1|DP-1")'
For the monitor status command, here's what i did to get it to work on my RPi3:
Create a script called "monitorstatus.sh":
#!/bin/bash
result=$(xrandr --listmonitors -d :0)
if [ "$result" = "Monitors: 0" ];
then
echo false
else
echo true
fi
make the script executable:
chmod +x monitorstatus.sh
Then add the custom command to the config:
monitorStatusCommand: '/path/to/script/monitorstatus.sh'
just in case it helps someone. here is what i just finally got to work
WAYLAND_DISPLAY="wayland-1" wlr-randr --output HDMI-A-1 --off
WAYLAND_DISPLAY="wayland-1" wlr-randr --output HDMI-A-1 --on
just in case it helps someone. here is what i just finally got to work WAYLAND_DISPLAY="wayland-1" wlr-randr --output HDMI-A-1 --off WAYLAND_DISPLAY="wayland-1" wlr-randr --output HDMI-A-1 --on
Can I know how do I get this to work on a schedule?
If I manually trigger the Wayland command in terminal, it works as per ON or OFF. But I have no luck setting a schedule. I tried cron but it doesn’t work or I’m doing it wrong.
do I install this remote control module and will be able to set a schedule or do I have to do some setting?
The power on\off commands in this module work for me. The randr work but reset my screen rotation when I run it to turn back on.
This crontab works.
#OFF 11PM
00 22 * * * root vcgencmd display_power 0
#ON 6AM
00 6 * * * root vcgencmd display_power 1
on rpi4 or rp5, it has 2 outputs. so xrandr --output HDMI-1 --auto not working.
Firstly you must find your monitors name. You can use that command for this:
xrandr -d :0
Response like this:
Screen 0: minimum 320 x 200, current 1080 x 1920, maximum 7680 x 7680
HDMI-1 connected primary 1080x1920+0+0 right (normal left inverted right x axis y axis) 16mm x 9mm
1920x1080i 60.00 + 50.00 59.94
1920x1080 24.00 23.98
1280x720 60.00 50.00 59.94
1024x768 75.03 70.07 60.00
1440x480i 59.94
832x624 74.55
800x600 72.19 75.00 60.32 56.25
720x576 50.00
720x576i 50.00
720x480 60.00 59.94
720x480i 60.00 59.94
640x480 75.00 72.81 66.67 60.00 59.94
HDMI-2 disconnected (normal left inverted right x axis y axis)
1920x1080 (0x47) 148.500MHz +HSync +VSync
h: width 1920 start 2008 end 2052 total 2200 skew 0 clock 67.50KHz
v: height 1080 start 1084 end 1089 total 1125 clock 60.00Hz
HDMI-1 connected primary 1080x1920+0+0 right (normal left inverted right x axis y axis) 16mm x 9mm
HDMI-1 is our display name.
at bookworm rpi 4 x64 use WAYLAND backend default. WAYLAND backend not response for --off command. you must change WAYLAND backend to Xorg (X11) backend. You can do that at below:
sudo raspi-config
Advanced Options -> Wayland -> X11 -> Save -> Reboot
now you can edit your config.js file like below:
config: {
customCommand: {
monitorOnCommand: 'xrandr -d :0.0 --output HDMI-1 --auto',
// monitorOnCommand: 'xrandr -d :0.0 --output HDMI-1 --mode 1920x1080 --rate 60 --rotate right',
monitorOffCommand: 'xrandr -d :0.0 --output HDMI-1 --off'
}
}