I'm a bit of a newbi when It comes to Ubuntu. But I've installed Ubuntu Server 17.04.
I'm running it on a laptop and I want to turn off the display. I'm running the commands with my admin account with root access.
I've tried the following with xset..
xset dpms force off
Which gives me the following error message..
xset: unable to open display ""
I've also tried using vbetool with the following code..
sudo vbetool dpms off
which gives me the following error message..
Real mode call failed
After googeling around I found a guy that did a Python script
#!/usr/bin/python
import time
import subprocess
from Xlib import X
from Xlib.display import Display
display = Display(':0')
#display = Display('0')
root = display.screen().root
root.grab_pointer(True,
X.ButtonPressMask | X.ButtonReleaseMask | X.PointerMotionMask,
X.GrabModeAsync, X.GrabModeAsync, 0, 0, X.CurrentTime)
root.grab_keyboard(True,
X.GrabModeAsync, X.GrabModeAsync, X.CurrentTime)
subprocess.call('xset dpms force off'.split())
p = subprocess.Popen('gnome-screensaver-command -i'.split())
time.sleep(1)
while True:
print display.next_event()
p.terminate()
break
and it gives me the following error message..
Traceback (most recent call last):
File "./script.py", line 8, in <module>
display = Display(':0')
File "/usr/lib/python2.7/dist-packages/Xlib/display.py", line 80, in __init__
self.display = _BaseDisplay(display)
File "/usr/lib/python2.7/dist-packages/Xlib/display.py", line 62, in __init__
display.Display.__init__(*(self, ) + args, **keys)
File "/usr/lib/python2.7/dist-packages/Xlib/protocol/display.py", line 58, in __init__
self.socket = connect.get_socket(name, host, displayno)
File "/usr/lib/python2.7/dist-packages/Xlib/support/connect.py", line 78, in get_socket
return getattr(mod, modname).get_socket(dname, host, dno)
File "/usr/lib/python2.7/dist-packages/Xlib/support/unix_connect.py", line 91, in get_socket
raise error.DisplayConnectionError(dname, str(val))
Xlib.error.DisplayConnectionError: Can't connect to display ":0": [Errno 2] No such file or directory
administrator@readytoserver:~/Scripts$
any ideas?
Would apprieciate some help from you guys since I feel this is a bit beyond me.