How to run script when switching to specific (already logged in) user
4
votes
0
answers
231
views
There's plenty of info out there on how to run a script at login (add it to .xprofile etc.), but I'm looking for a solution that will run a script/command not just at login but *also* every time a particular user's session is activated/brought to the foreground.
### Concrete Example ###
I have two users on my system, John and Jane. On a typical day, John logs on to a graphical session in the morning, adjusts his settings the way he likes (for argument's sake, he works with the display backlight at 100%), does an hour of work, and then locks his session (but *does not* log out). A while later, Jane logs in, sets the backlight to 0%, does some work, locks her session, and leaves.
My issue is now, when John comes back, he unlocks and reactivates his earlier session. He curses Jane for setting the backlight to 0% again, and because he's not logging in to a new session, there's no option to automate backlight adjustment by adding commands to .xprofile or .xsessionrc
### My Setup ###
I'm on debian buster with lightdm and xfce
### Things I've Tried ###
The closest I've come to a solution is listening to dbus-monitor --system for lightdm or systemd-logind messages to hook into, but I just don't know how to identify a specific enough message trigger (specific to user and to session activation)
### Question ###
How can one ensure a script gets run every time a particular user unlocks/reactivates his/her graphical session?
Asked by user629422
(41 rep)
Aug 2, 2020, 09:05 AM
Last activity: Aug 16, 2020, 12:42 PM
Last activity: Aug 16, 2020, 12:42 PM