I want to add a Custom Shortcut (Keyboard → Custom Shortcuts → Add) for turning off the display but to do that, what 'Command' should I should use?

I want to set a button to switch off the display and switch on.

  • I have tried this my self and placed here. 100% working. – rɑːdʒɑ Oct 31 '13 at 14:24
$ xset dpms force off

Screen wakes up after moving the mouse or pressing a key.

Manually turn off monitor

  • Thats working, Thank U! I used command as 'xset dpms force off'! – Gaurav Oct 31 '13 at 14:14

open your terminal and type as

sudo apt-get install python-xlib

after installing it ,type as

gedit monitoroff.sh

and paste the following code


import time
import subprocess
from Xlib import X
from Xlib.display import Display

display = Display(':0')
root = display.screen().root
        X.ButtonPressMask | X.ButtonReleaseMask | X.PointerMotionMask,
        X.GrabModeAsync, X.GrabModeAsync, 0, 0, X.CurrentTime)
        X.GrabModeAsync, X.GrabModeAsync, X.CurrentTime)

subprocess.call('xset dpms force off'.split())
p = subprocess.Popen('gnome-screensaver-command -i'.split())

while True:
    print display.next_event()

Then type as

chmod +x monitoroff.sh

Then open your unity dash and type as keyboard and open it.

after opening it click at + symbol to add it.

Then in the name field type name as monitor off & at command field type path of the script. In my case it is ~/monitoroff.sh

after adding it click ok.

then select it with mouse and then press your hotkey , in my case it is F11.

to power on your mouse again click your mouse or press escape key .

Then enter image description here

enter image description here

  • Yeah let me know if any... – rɑːdʒɑ Nov 1 '13 at 5:12

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.