2016-10-23 - screen saver

whenever i walk away from the computer i lock it. i used to use 2 modes:

it worked well, but i had to turn off monitors after using xscreensaver, since it had no option to blank the screen when locked, but do NOT ever blank screen when not locked. more over, when i've tried to do:

xset dpms force off

to blank it after screen gets locked, xscreensaver restored screen backlight again.

recently i've decided to finally solve it. i never liked xscreensaver, since it was big, required background process to run and did not solve my problem, really.

xtrlock stayed for locked-with-overview mode, as before. regarding the screen-hiding solution, the requirements are:

it turned out, that all of this can be done with xtrlock, with a minimal scripting!

to prevent screen from ever sleeping i use prevent_monitor_sleep script:

xset -dpms
xset s noblank
xset s off

when locking, screen is blanked with extra option to xtrlock, and then power saving features are forced-turned on. when UI is idle, screens are turned off after 30[s] too (see: xprintidle). script is called blank-lock and does (roughly) this:

function monitor_inactivity
{
  while true
  do
    no_action_for_30s && xset dpms force off
  done
}
 
monitor_inactivity &
 
logger "locking screen"
xtrlock -b
logger "screen unlocked"
 
kill inactivity_monitor
prevent_monitor_sleep

a very nice thing about xtrlock is that it (by default) blocks until screen get unlocked. this means you can easily log time when screen got locked and unlocked. it's a very neat feature for work, since you can see what time did you arrived and when did you left. :)

btw: for the “funny facts” part – xtrlock was less than 300 lines of code in C… :)