1

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.

3
  • Well, not really true. If I start the laptop the display is constantly on and displaying a "login" prompt. I don't see how I can run the computer with the monitor off? besides the monitor works perfectly fine to issue commands to the server from even though I mostly use Putty and my other computers.
    – Thomas S
    Jul 20, 2017 at 20:25
  • All the code you refer to is for the GUI, which you don't have.
    – user68186
    Jul 20, 2017 at 20:29
  • Ok, I see. But still, there's a monitor plugged into the laptop running ubuntu server and I ought to be able to deactivate the monitor ? Should I try a different approach and use bios?
    – Thomas S
    Jul 21, 2017 at 10:54

1 Answer 1

1

This issue was not present on 16.04. The LCD automatically turned off on the laptop after period of time but if lid closed went to sleep.

I resolved this issue for my Lenovo T410 as after I installed 18.04 and upgraded to 18.04.1 the LCD turned off unless I closed the lid of the laptop and that puts it to sleep.

Now I can lower the lid till the LCD shuts off or completely close the lid and it doesn't go to sleep.

Resolution is to edit file: /etc/systemd/logind.conf

HandleSuspendKey=ignore
HandleLidSwitch=ignore

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .