2016-10-23 - screen saver

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

  • xtrlock to lock the screen, while still being able to see what's happening there (progress bars, stats, etc…).
  • xscreensaver for locking, when i wanted to keep desktop hidden.

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:

  • screen-saver must be daemon-less.
  • it should be activated on demand only.
  • it should display black screen and just prompt for password.
  • when idle, monitors should be turned off shortly.
  • monitors get turned on, on user interaction.
  • monitors never go into any sleep/off/standby mode when screen is unlocked.

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
    no_action_for_30s && xset dpms force off
monitor_inactivity &
logger "locking screen"
xtrlock -b
logger "screen unlocked"
kill inactivity_monitor

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… :)

blog/2016/10/23/screen_saver.txt · Last modified: 2021/06/15 20:09 by
Back to top
Valid CSS Driven by DokuWiki Recent changes RSS feed Valid XHTML 1.0