Thread: Turn Off Monitor/Screen (and Make it Stay OFF)
hi again,
i've read several posts here on how turn off laptop screen in ubuntu using script/command, none seem have worked me except one.
after digging around, found following suggestions:
1. xset dpms force off
or xset dpms force suspend
didn't work many people, nor did work me, monitor turn on again after few seconds. second other suggestion found make "stick was:
2. sleep 1; xset dpms force off
or sleep 1; xset dpms force suspend
worked people, delaying monitor off function 1 second, did not work me, monitor turn on again after 1 minute exactly. maybe thought solution walked away , never found out monitor plays sneak-peak them. next solution found digging around supposed make monitor stay powered off:
3. sleep 1; && xset dpms force off
or sleep 1; && xset dpms force suspend
didn't work either; disappointment, , made cpu , hdd freak out while while monitor off. after more digging around, came following: (and don't remember got this, whether here or elsewhere on internet, if creation, please contact me , i'll edit post give credit)
4. create file , save monitor_off.sh in folder of preference following in it:
---------------------------------------
#!/usr/bin/python
import time
import subprocess
xlib import x
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
---------------------------------------
go to: system>preferences>keyboard shortcuts , assign keyboard combination shortcut call , initiate script. chose "<ctrl>+m" because it's easy remember.
make sure disable same keyboard shortcuts may have in compiz avoid conflicts.
final script worked me. , monitor stays off until shake mouse or press key on keyboard, , cpu , hdd don't rev harley. final solution seems working of friends without glitch.
if want add anything, i'll leave thread open week, in case there few suggestions can improve idea or add new features or simplify it. thought idea post here because i've seen many people looking taking control of such feature, , great.
thank you.
thanks. works charm me.
maybe put code within
and user needs install python-xlib work.code:code tag doesn't lose formatting?
Forum The Ubuntu Forum Community Ubuntu Official Flavours Support Multimedia Software [ubuntu] Turn Off Monitor/Screen (and Make it Stay OFF)
Ubuntu
Comments
Post a Comment