Author Topic: Using GSD/Ruby to control display power with DPMS?  (Read 9242 times)

colinjones

  • Alumni
  • LinuxMCE God
  • *
  • Posts: 3003
    • View Profile
Using GSD/Ruby to control display power with DPMS?
« on: February 13, 2009, 11:39:30 pm »
Can someone tell me is it possible to execute simple shell commands within the Ruby snippets of a GSD?

I have a small LCD connected to one of my MDs for the bedroom.... currently I just switch the power on and off manually to this display as I need it. But was thinking as it is connected using VGA I can use DPMS signalling to put it into power save/off mode. Rather than go to the extent of using an IR blaster, I was thinking I could create a Device using GSD, implement only the Power On and Off commands, and in the Ruby snippets execute:

xset dpms force off

and

xset dpms force on

Then just allow LMCE to control it as needed. This avoids the expense, extra equipment clutter and potential unreliability of IR blasting, is free, simple and completely reliable!

Just need to know how to execute shell commands in Ruby, the serial part becomes irrelevant :)

krys

  • Addicted
  • *
  • Posts: 583
    • View Profile
Re: Using GSD/Ruby to control display power with DPMS?
« Reply #1 on: February 13, 2009, 11:56:43 pm »
collin,
Just build a template for the monitor as a GSD device, and for the power on off commands use:
system("xset dpms force off")
system("xset dpms force on")

make sure to set the monitor up as a video pipe and you should be set. This is how mine is working.

colinjones

  • Alumni
  • LinuxMCE God
  • *
  • Posts: 3003
    • View Profile
Re: Using GSD/Ruby to control display power with DPMS?
« Reply #2 on: February 14, 2009, 12:07:20 am »
collin,
Just build a template for the monitor as a GSD device, and for the power on off commands use:
system("xset dpms force off")
system("xset dpms force on")

make sure to set the monitor up as a video pipe and you should be set. This is how mine is working.

Thanks Krys, actually just found that and I'm trying to create the GSD device now... the command I found was
system "asdasdsa"
here http://ubuntuforums.org/showthread.php?t=63224

But my problem is I don't seem to be able to create a GSD that allows me to edit the ruby code!


colinjones

  • Alumni
  • LinuxMCE God
  • *
  • Posts: 3003
    • View Profile
Re: Using GSD/Ruby to control display power with DPMS?
« Reply #3 on: February 14, 2009, 12:25:34 am »
I have created a GSD, but every time I go into the template and hit Edit Ruby Codes, the window that comes up indicates that the Power, Inputs and DSP Modes groups are there, and has the links to create the On and OFF commands. But when I go into these and enter the Ruby code and hit save it goes back and still says those commands are not implemented.... I just don't seem to be able to add the code snippets...

krys

  • Addicted
  • *
  • Posts: 583
    • View Profile
Re: Using GSD/Ruby to control display power with DPMS?
« Reply #4 on: February 14, 2009, 06:03:47 am »
weird, did you select rs232 as the codeset? I am looking at my template and just dont see anything out of the ordinary that I did. I will sleep on it, maybe talk with TSCHAK, he is the one who hooked me up.

colinjones

  • Alumni
  • LinuxMCE God
  • *
  • Posts: 3003
    • View Profile
Re: Using GSD/Ruby to control display power with DPMS?
« Reply #5 on: February 14, 2009, 06:12:20 am »
Something very strange was happening - on the AV properties the pop up window kept coming back with an error retrieving the IR codes, every time I went into the ruby editor and some other windows, it would take about 15-20 secs to populate the page, I haven't seen that before. I chose the conn method of Unknown because it isn't actually communicating with anything. Then I realised that somehow I had created 2 templates with identical names, because every time I edited the template it wasn't being reflected in the device! Then I realised I was picking the wrong template! There was a struggle to get the inputs there as well so I could setup the pipe. But finally I got it all working and sending the signals. It now switches off automatically after the timeout, and manually when I hit power. The only problem now is I've realised that even mouse movement is enough to "wake" it up again so it is impossible to power the display off manually from a gyro or Fiire remote!

seth

  • Guru
  • ****
  • Posts: 485
  • A day w/o LinuxMCE is like a day w/o sunshine!
    • View Profile
Re: Using GSD/Ruby to control display power with DPMS?
« Reply #6 on: March 10, 2009, 05:54:28 pm »
 :)
I received a 22" LCD screen for one of my MD's. Could someone please outline or wiki the steps to create this device?

Here is what I have done.

1. Created the Generic Serial Device for the 22" LCD
2. Edited the ruby codes created a codeset called DMPS
3. Clicked under Power the link for "On" - added - system("xset dpms force on")
4. Clicked under Power the link for "Off - added - system("xset dpms force off")
Under Pipes I created a video pipe from Playroom MD to 22" LCD

Now I am not sure how to use it, or even if this was the correct way.

Please advise, this will enable me to utilize the USB-UIRT connected there elsewhere, It is an IR controlled 22"LCD HDTV/DVD combo, which I use a MCE remote to control, and I would like to use the USB-UIRT also connected there on my TestBed.

Thanks,

Regards,

Seth
".....Because Once you've LinuxMCE'd....."
System stats located at my user page:

http://wiki.linuxmce.org/index.php/User:Seth

krys

  • Addicted
  • *
  • Posts: 583
    • View Profile
Re: Using GSD/Ruby to control display power with DPMS?
« Reply #7 on: March 10, 2009, 06:17:08 pm »
This command does not go through IR, I believe for it to work the monitor must be connected via VGA. To use it you just pull up your orbiter and go to Power> display off/on. Should work for ya!
If you want to test whether it works for your monitor you can just go to shell and type

xset dpms force off


seth

  • Guru
  • ****
  • Posts: 485
  • A day w/o LinuxMCE is like a day w/o sunshine!
    • View Profile
Re: Using GSD/Ruby to control display power with DPMS?
« Reply #8 on: March 10, 2009, 06:22:34 pm »
 :)
hey thanks for the quick response.

This is plugged into the VGA port on the back of a Compaq Evo w/ intel graphics. I have it connected 720P just as though it were a computer monitor. I currently have the IR codes learned, and have the device as an AV Device assigned to that room. But I have need for the USB-UIRT in my test environment, so I figured I could use the DMPS off feature, and the volume internal to the MD rather than use IR for everything.

I will test this when I get home this evening, and post back my findings.

Again I appreciate your reply. Got to love it when you get a response back that quickly. Thanks Again!  :)

Regards,

Seth
".....Because Once you've LinuxMCE'd....."
System stats located at my user page:

http://wiki.linuxmce.org/index.php/User:Seth

colinjones

  • Alumni
  • LinuxMCE God
  • *
  • Posts: 3003
    • View Profile
Re: Using GSD/Ruby to control display power with DPMS?
« Reply #9 on: March 10, 2009, 09:23:03 pm »
Correct, this has nothing to do with IR, it is signalled through the sync pins on the VGA connector. The device you create is a GSD one, I set the Comm Method to unknown... don't think this really matters that much. You need to make sure the Controlled By is the MD device that the monitor is connected to and the room/entertainment areas are correct. This in addition to ensuring there is a video pipe from the MD to the VGA Monitor device you are creating. Check the device log when it starts to make sure it is happy with the Ruby and starts up correctly. And make sure that the devices is "Registered: Yes" once started. Then you can either use the power menu as Krys mentions, or simply wait - after the timeout, LMCE will automatically trigger the Off command and send it down the audio and video pipes in that entertainment area, which ends up hitting your new devices, which interprets this command and executes the Ruby snippet cutting off the screen...

The only time I have seen it no reliable was after a scheduled event I had running each morning playing music. The screen was off, the event would trigger and the screen would come on. I would kill the music after a minute or so, and the screen would never turn off again. Btw, there is an annoying factor - unfortunately, LMCE considers even mouse movement to be a wake up trigger. This makes it very difficult to turn the power off with a gryo remote, and moderately difficult with a mouse. Clearly there is no reason for mouse movement to be considered "activity" this should be limited to actual button presses, then the mechanism would be complete.... have yet to log a bug ticket for this...

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Using GSD/Ruby to control display power with DPMS?
« Reply #10 on: March 11, 2009, 12:31:36 am »
I will make a special version of the Generic_PC_Workstation, for Generic_PC_Monitor, which will be identical, however, it will be registered as a A/V TV, which will allow it to be selected from the Setup Wizard.

My code actually incorporates the raw X DPMS calls, avoiding the mess of exiting to the shell.

-Thom

colinjones

  • Alumni
  • LinuxMCE God
  • *
  • Posts: 3003
    • View Profile
Re: Using GSD/Ruby to control display power with DPMS?
« Reply #11 on: March 11, 2009, 01:22:36 am »
I will make a special version of the Generic_PC_Workstation, for Generic_PC_Monitor, which will be identical, however, it will be registered as a A/V TV, which will allow it to be selected from the Setup Wizard.

My code actually incorporates the raw X DPMS calls, avoiding the mess of exiting to the shell.

-Thom


Cool, thanks Thom. I did some ferreting around the pnp side of things... unfortunately, it looks like connecting a monitor to the VGA port does not trigger anything at all in the HAL that the HAL DCE device could use as a pnp trigger to auto install this device. In fact, I couldn't really find any simple way of detecting a VGA monitor being connected, at the time, so that even a new pnp event device could be created around this. Would be nice, though, if connecting a VGA monitor threw up some screens asking if you wanted LMCE to control its power automatically... and installed your DCE device if the user hits 'yes'

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Using GSD/Ruby to control display power with DPMS?
« Reply #12 on: March 11, 2009, 02:31:02 am »
Yeah, it would.

But until we can figure that out, you can add it in the setup wizard, and it will work just fine. :)

Basically the TV will have ONE port, the PC port, and you just connect that to the media director in the setup wizard.

-Thom

colinjones

  • Alumni
  • LinuxMCE God
  • *
  • Posts: 3003
    • View Profile
Re: Using GSD/Ruby to control display power with DPMS?
« Reply #13 on: March 11, 2009, 03:07:42 am »
So the "Sara" wizard allows you to install this device even though it isn't pnp? great!

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Using GSD/Ruby to control display power with DPMS?
« Reply #14 on: March 11, 2009, 03:09:15 am »
Yeah, it's just another TV. :)

-Thom