Kategorier
Tips og triks

Run scripts when locking/unlocking screen in Ubuntu 14.04+

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
)

Legg igjen en kommentar

Din e-postadresse vil ikke bli publisert. Obligatoriske felt er merket med *

Dette nettstedet bruker Akismet for å redusere spam. Lær om hvordan dine kommentar-data prosesseres.