0

I want a Linux (Ubuntu) program to be able to enable and disable the console screen as needed.
When I run this in a ssh window I can use:

system("xset -display :0 dpms force on")

and

system("xset -display :0 dpms force off") 

to get what I need; however if I launch it from /etc/rc.local that doesn't work. Is there a good way to progammatically enable/disable the display?

gtonic
  • 2,295
  • 1
  • 24
  • 32
Ed.
  • 928
  • 1
  • 10
  • 23
  • `/etc/rc.local` runs when the system starts, probably before the X server has started. Or you are doing it from a long running program? – rodrigo Oct 14 '16 at 21:22
  • Its a long running program that starts in /etc/rc.local. So the X server is certainly up and running. I guess I don't know much about how applications hook to facilities provided by X; especially if being launched in rc.local (not from a terminal). – Ed. Oct 16 '16 at 14:25
  • Then it may be a duplicate of [this other question](http://stackoverflow.com/questions/20395027/scripts-launched-from-udev-do-not-have-display-access-anymore). – rodrigo Oct 16 '16 at 15:55
  • Thanks for the pointer, I'm digging into that now. It appears to still do some "X"-ish stuff just to wake up the console. I guess my more fundamental question is "can't this be done without "X"?. – Ed. Oct 17 '16 at 12:30
  • Well, I don't want to post this as the answer, but I did find a way around my problem... Instead of launching the program through /etc/rc.local, I do it with an autostart file under .config/autostart (for a localuser). This allows the "xset" in my program run as expected. Ideally, I'd still like to know how to do this without dependence on 'X'. – Ed. Oct 17 '16 at 13:43
  • Well, obviously, you won't be able to use `xset` without an X server. Your problem with the X server is probably related to the authorization, as in the linked answer. – rodrigo Oct 17 '16 at 19:04
  • Yea of course. But there's got to be a way to interact with the screen saver without the need for "xset" or the x server behind it. Thanks... – Ed. Oct 18 '16 at 11:44

0 Answers0