Catching user switching and getting current active user from root on linux

Tim Harig usernet at ilthio.net
Tue Nov 30 17:54:49 EST 2010


On 2010-11-30, mpnordland <mpnordland at gmail.com> wrote:
> I have situation where I need to be able to get the current active
> user, and catch user switching eg user1 locks screen, leaves computer,
> user2 comes, and logs on.
> basically, when there is any type of user switch my script needs to
> know.

Well you could use inotify to trigger on any changes to /var/log/wtmp.
When a change is detected, you could check of deltas in the output of "who
-a" to figure out what has changed since the last time wtmp triggered.



More information about the Python-list mailing list