I probably found a solution (for xfce environments only)
In short, I modified the script to save the current user in a variable before starting the while loop; then it checks the current owner of the xfdesktop process in every loop. If the two do not match anymore, the script breaks the loop and exits:
Code:
#!/bin/bash
ORIGINAL_USER="$( id -u -n )"
# Main loop
while [ 1 ]
do
# ... do stuff
# Check current user; if it changed, exit
CURRENT_USER="$( ps aux | grep [x]fdesktop | awk '{print $1}' )"
if [ ! "$CURRENT_USER" == "$ORIGINAL_USER" ]; then
break
fi
sleep 5
done
exit 0
I guess that a more general (i.e. valid for all graphical environments) solution exists, but in my box it works
Bookmarks