bash - How to turn ON/OFF screen monitor using shell script and 'xrandr' linux command? -
i trying turn on , off screen monitor in ubuntu14.04 using key bindings.
tried following shell script:
#!/bin/sh output=$(xrandr | grep ' connected ' | awk '{print $1}' | head -1) screensize=$(xrandr | awk 'begin {foundoutput=0} / '$output' / {foundoutput=1} /\*\+/ {print $1} /^[^ ]/ {if(foundoutput) exit 0}') if [ "$screensize" != "" ]; xrandr --output $output --fb $screensize --off espeak "monitor off" else xrandr --output $output --auto espeak "monitor on" fi 1) above script working fine in ubuntu 10.04, not working in ubuntu 14.04.
2) bind script on ctrl+alt+m key.
3) when press key binding off monitor again pressed key binding not start screen monitor.
4) try run command
xrandr --output $output --auto or
xrandr --output lvds-1 --auto but nothing happens.
5) tried command
xset dpms force off but if key pressed start screen monitor.
so should turn screen monitor on or off using shell script?
often times laptop have it's own screen key binding turns on , off display. if laptop has no such key, try searching programs other xrandr want. ubuntu's default screensaver can assign key automatically turn off , lock screen.
- navigate system settings > keyboard > shortcuts > system.
- click
+, name custom shortcut want, , put commandgnome-screensaver-command -la. - click apply, assign shortcut want add.
these instructions can found here (with pictures): askubuntu.com/questions/446601/how-can-i-lock-and-blank-the-screen-from-the-keyboard-in-14-04 might able xrandr work settings manager, don't know.
Comments
Post a Comment