EDBloggen

Alexander Karlstad. Blogger hovedsakelig om Linux og sånt.

Arkiv for stikkordet «lock screen»

Run scripts when locking/unlocking screen in Ubuntu 14.04+

ingen kommentarer

After upgrading to Ubuntu 14.04 the old way of binding scripts to run when locking or unlocking my screen stopped working, but after investigating using the dbus-monitor, I found that the DBus event had changed, so here is a way of doing it nowadays:

dbus-monitor --session "type='signal',interface='com.ubuntu.Upstart0_6'" | \
(
  while true; do
    read X
    if echo $X | grep "desktop-lock" &> /dev/null; then
      custom-lock-command-here;
    elif echo $X | grep "desktop-unlock" &> /dev/null; then
      custom-unlock-command-here;
    fi
  done
)

Skrevet av Alexander Karlstad

3. september 2014 klokken 01.57

Optimization WordPress Plugins & Solutions by W3 EDGE