Wednesday, April 15, 2015

xmonad and screen off

In Ubuntu with default windows manager it just works, with Xmonad it doesn't, turning the screen off and making the eco-people happy (saving your electricity bill).

The inspiration for solution comes from:
http://superuser.com/questions/590225/disable-screen-turn-off

Checking xset tool in terminal shows smth:
xset
usage:  xset [-display host:dpy] option ...
    To turn bell off:
 -b                b off               b 0
    To set bell volume, pitch and duration:
  b [vol [pitch [dur]]]          b on
    To disable bug compatibility mode:
 -bc
    To enable bug compatibility mode:
 bc
    To turn keyclick off:
 -c                c off               c 0
    To set keyclick volume:
  c [0-100]        c on
    To control Energy Star (DPMS) features:
 -dpms      Energy Star features off
 +dpms      Energy Star features on
  dpms [standby [suspend [off]]]     
       force standby 
       force suspend 
       force off 
       force on 
       (also implicitly enables DPMS features) 
       a timeout value of zero disables the mode 
    To set the font path:
  fp= path[,path...]
    To restore the default font path:
  fp default
    To have the server reread font databases:
  fp rehash
    To remove elements from font path:
 -fp path[,path...]  fp- path[,path...]
    To prepend or append elements to font path:
 +fp path[,path...]  fp+ path[,path...]
    To set LED states off or on:
 -led [1-32]         led off
  led [1-32]         led on
 -led named 'name'   led off
  led named 'name'   led on
    To set mouse acceleration and threshold:
  m [acc_mult[/acc_div] [thr]]    m default
    To set pixel colors:
  p pixel_value color_name
    To turn auto-repeat off or on:
 -r [keycode]        r off
  r [keycode]        r on
  r rate [delay [rate]]
    For screen-saver control:
  s [timeout [cycle]]  s default    s on
  s blank              s noblank    s off
  s expose             s noexpose
  s activate           s reset
    For status information:  q
    To print version: -version

The interesting part is dpms. To force turn off the screen one has to run:
xset dpms force off
And it would be great to integrate it with a 'lock screen' keyboard shortcut in Xmonad configuration:
    -- lock screen
     , ((modm .|. shiftMask, xK_l     ), spawn "gnome-screensaver-command -l && xset dpms force off")

No comments:

Post a Comment