Jopyth/MMM-Remote-Control

How to make monitor commands work for more people

DanielHabenicht opened this issue · 3 comments

Hi! Thanks for this brilliant module.

In order to make the monitor commands work for my pi configurations, I had to change them to echo 0 | sudo tee /sys/class/backlight/rpi_backlight/bl_power or sudo /opt/vc/bin/tvservice -p && sleep 1 && DISPLAY=:0 && xset dpms force on (for the official 7" screen, or an hdmi connected monitor)

My question is how to implement all those different ways of turning on and off a display so it works out of the box with your module.
Should I just add some logic to the following part, which executes every possible command and returns true if at least one of the executed commands returns without error?

let monitorOnCommand = (this.initialized && "monitorOnCommand" in this.thisConfig.customCommand) ?
this.thisConfig.customCommand.monitorOnCommand :
"vcgencmd display_power 1";
let monitorOffCommand = (this.initialized && "monitorOffCommand" in this.thisConfig.customCommand) ?
this.thisConfig.customCommand.monitorOffCommand :
"vcgencmd display_power 0";
let monitorStatusCommand = (this.initialized && "monitorStatusCommand" in this.thisConfig.customCommand) ?
this.thisConfig.customCommand.monitorStatusCommand :
"vcgencmd display_power -1";

The way to add those commands it's by using the config file. I don't recommend changing any of the files from inside the Remote Control folder, because in every new version those changes will be lost. In the Wiki over here you can see examples of how to change every command.
If you use both turn on and off, you will need to set the status command too. In the wiki it's explained in detail. If you need more help, I'll be glad to help you here. :D

Yeah sure, I am doing that in the config already. I just think that more people have the same problems so I wanted to ask on how to add it to this GitHub repo, so it works out of the box for even more people.

A lot of people will never agree with monitor status change or even shutdown. That's why the config file it's the salvation for all of them.

We cannot add some commands that will work just for one or two people, because that will increase considerably the code and will not be maintainable.

We could add notes inside the Wiki for some major OS, or if you feel that something needs a change, just add it as a PR or an issue.

But believe me when I say that changing a few lines of code could break it entirely. And it's better that those who know what they're doing figure those commands and adds them inside the config file.