I have a different user for each of my own work areas on my system. This is to keep bookmarks, files and other defaults separate.
Several "users" are generally logged in at once and I just switch between them when I change which project I'm working on in that moment.
I am using Ubuntu 18.04 with Gnome Desktop Environment
I'd like to keep track of when I've been working on different projects and I figured tracking these sessions would be an easy way to do this, however I don't know if there is a log available that knows which user is using the GUI at any one time, or how to create such a tracker.
The two details I think are needed for the tracker are: 1.) Events where a user logs in, including the times when the user is unlocking a session that is already open 2.) When screen locks due to inactivity
Does anyone know if these are already/can be logged?
Thanks! Woody
Solution: ( With help from meuh below and this question: How to run a script on screen lock/unlock? )
This following script needs to be run from ~/.profile for each user that I wish to keep track of, their login/logout times all get logged in the OUTPUTFILE
The initial echo is because the script only gets run after the user has logged in and would otherwise be missed. All subsequent logins are caught from dbus-monitor
#!/bin/bash
echo $(date), $USER, SCREEN_UNLOCKED >> OUTPUTFILENAME
dbus-monitor --session "type='signal',interface='org.gnome.ScreenSaver'" |
while read x; do
case "$x" in
*"boolean true"*) echo $(date), $USER, SCREEN_LOCKED >> OUTPUTFILENAME;;
*"boolean false"*) echo $(date), $USER, SCREEN_UNLOCKED >> OUTPUTFILENAME;;
esac
done