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.

  1. navigate system settings > keyboard > shortcuts > system.
  2. click +, name custom shortcut want, , put command gnome-screensaver-command -la.
  3. 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

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -