Ubuntu Raring Ringtail (13.04) from fresh installation.


Main: Change gsetting (desktop wallpaper) with script on user logout.

What's I've Done : (carefully read)

I try to stop an application named variety (this one) on Logout that I've put my workarounds inside. Variety is an autostart app, so it just started everytime I'm logging in. Variety has a function on_quit() and force_quit_thread() that are called when the app process stopped. So, I added my python script line inside, that execute my real script (normalize). When I tried to quit variety normally, it does what I want! I though, when the system log me out, any process that I started should also be stopped. But then, I realized, it is not. So, I couldn't use this way.

This let me thing to use another way to kill variety process manually when I logging out. I have tried ~/.bash_logout (I doubt it, because I know autostart does not run on bash); ~/etc/gdm/PostSession/Default (But, I'm not use gdm); ~/etc/lightdm/lightdm.conf (This one doesn't work either! How come?); pam_script / pam-script (I don't know how to work with it. Really different.)


But, the problem comes when I try to log out my account. It neither execute on_quit() nor force_quit_thread(). And the log I captured from ~/nohup.out see last line, here you are:

.... bla-bla ... [only see last line]
IOError: [Errno socket error] [Errno 2] No such file or directory

(variety:15627): Gdk-WARNING **: variety: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.

They lost available resources, right? Not quit-ed normally then and means, gsetting not changed.


  1. Added script inside quit functions

    It is on /opt/extras.ubuntu.com/variety/variety/VarietyWindow.py:

    bashCommand = "/home/abdillah/Toolbox/command/normalize"
  2. Script inside normalize

    Purpose: changing wallpaper when variety quit.

    echo $(cat "${HOME}"/.self-log)"| normalize" > "${HOME}"/.self-log #append log
    wallpaper=$(cat /home/abdillah/.wallpaper)
    gsettings set org.gnome.desktop.background picture-uri $configname #the most important
  3. LightDM config file

    The one that make me confuse is that in it's documentation, there isn't a statement mentioned session-cleanup-script. It is deprecated?

  4. logoff file contains:

    .self-log file still empty => fail

    echo $(cat "${HOME}"/.self-log)" |fail? (OnScript)" > "${HOME}"/.self-log #append log
    killall variety
    /opt/extras.ubuntu.com/variety/bin/variety -q
    echo $(cat "${HOME}"/.self-log)" |Success? (OnScript)" > "${HOME}"/.self-log #log
    exit 0


When anyone think, above condition is very specific, just answer the following question.

  1. How to executing script directly on logout (CMIW the ways above. If not, any suggestion please), or
  2. How I can stop variety properly when I logged out? (So on_quit() called)

Possible Solution

  • Start variety with [StartUpApplication] in bash and use ~/.bash_logout script to stop. But, how?

Ok. its long. But, I try to make as clear as possible. Because out there, there are lots of question related with this that I've read.

  • I think that gsettings reset org.gnome.desktop.background picture-uri might be a little better. May 13, 2013 at 21:16

1 Answer 1


The solution is not straightforward. It requires start of script at X login and waiting till the and of X session. Fortunately we have inotify and pid of gnome-session.

Variety process should already be killed properly at the time of script execution.

  1. Install inotify-tools package.
  2. Create or modify ~/.xprofile script and add to it following line

    sh .xlogout &
  3. Create ~/.xlogout with following content

    FILE=/tmp/.ICE-unix/$PPID            # pid of parent = gnome-session
    sleep 10s                            # wait for $FILE creation
    inotifywait -qe delete_self $FILE    # wait for $FILE deletion = logout
    # your code goes here                # = on_quit
    # gsettings reset org.gnome.desktop.background picture-uri

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.