The good old session bug

Ray Andrews rayandrews at eastlink.ca
Tue Dec 11 05:54:49 CET 2012


What do you guys think of this, it works here.

# Script: check-xfce-session

#!/usr/bin/zsh

# When the XFCE 'sessions' bug occurs on logout, the 'state' file will 
not be updated.
# The 'session' file will be updated, but it is corrupt. A fix can be 
had by comparing
# the timestamps of the two files, and restoring a good copy of the 
'session' file
# from a backup if they differ. So far, I can't see any benefit from 
saving/restoring a
# copy of the  'state' file as well as the 'session' file. This script 
should probably be called
# from '/etc/xdg/xfce4/xinitrc' just after the line 'xfce4-session', but 
it can be run
# manually from CLI too.

# Grab the timestamps:
var1=`ls -l --time-style=+%s ~/.cache/sessions/xfwm4-*.state    | awk 
'{print$6}'`
var2=`ls -l --time-style=+%s ~/.cache/sessions/xfce4-session*:0 | awk 
'{print$6}'`

# Let's add a couple of seconds just incase there's some honest delay in 
writing :
let var3="$var1"+2

if [[ "$var3" < "$var2" ]]; then
echo "\n\e[32;1mIt looks like you've triggered an XFCE 'sessions' bug 
LOOSER.
The time of the \'state\'   file is: $var3, but
the time of the \'session\' file is: $var2, so you are in deep doo-doo.
On restarting XFCE, you can expect to see a big 'X' as your cursor, and you
won't have any window borders.  This happens because people like YOU 
need to be
a bit more careful making sure they don't have any unsaved 'gedit' 
documents
open when they log out. How hard can that be? But all is not lost, we 
can try to
resore the last good session.

Would you like to restore the backup session?
'n' or 'N' for 'NO' or any other key to restore ...\e[0m"

read -sk keystroke
if [[ "$keystroke" = [nN] ]]; then
   return 2;
fi

cp -v ~/.cache/sessions/backup/xfce4-session*:0 ~/.cache/sessions/
return 1

else
echo "\n\e[32;1mThis is your lucky day, it seems your xfce session has 
quit without trouble.\e[0m\n"
return 0
fi

=========================================

I call it here, in /etc/xdg/xinitrc: (Note mine is modified, but you get 
the idea)

     xfce4-session


zsh /home/ray/aRay/Bin/Zsh/check-xfce-session

     if test "$ssh_agent_kill_cmd"; then
         echo "running '$ssh_agent_kill_cmd'"
         eval "$ssh_agent_kill_cmd"
     fi

===============================================

Sorry, it's a zsh script, I didn't try to make it 'sh' compatible. To 
make it work, create:

~/.cache/sessions/backup/

and copy a copy of a session file (eg. xfce4-session-xxxxxx:0)  that you 
are happy with into there and the above script will restore it if the 
sessions bug strikes.  It works for me, tho I remove the prompting and 
do the restore automatically. Feedback appreciated.




More information about the Xfce mailing list