Exist a log where I can look for that information? I want to know last days when my PC automatically locked the screen because was idle.

share|improve this question
up vote 9 down vote accepted

You can find the unlock screen events using the following command:

grep screen /var/log/auth.log*

But there is not so simple to find the lock screen events because by default doesn't exist any log for these events (as far as I know).

Anyway, you can run the following command for logging the lock screen events:

dbus-monitor --session "type='signal',interface='org.gnome.ScreenSaver'" | ( while true; do read X; if echo "$X" | grep "boolean true" &> /dev/null; then  echo "Screen locked on $(date)" > $HOME/lock_screen.log; fi; done )

in ~/lock_screen.log file.

If you like the above command, then use it in a script and make the script to run automatically at startup.

References:

share|improve this answer
    
doesn't seem to work on ubuntu 17.04. The ouput of dbus-monitor --session "type='signal',interface='com.ubuntu.Upstart0_6'" is signal time=1497336035.520628 sender=org.freedesktop.DBus -> destination=:1.140 serial=2 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired string ":1.140" signal time=1497336035.520706 sender=org.freedesktop.DBus -> destination=:1.140 serial=4 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameLost string ":1.140", then nothing when I lock or unlock – maxou Jun 13 '17 at 6:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.