1

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
2
$ 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
0

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

#!/usr/bin/python

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

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

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.