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 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.
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