Search code examples
linuxxfce

How to execute a script when xfce session ends


Is it possible to run a script/command when the xfce session stops ?


Solution

  • Change the /usr/bin/xfce4-session executable with a shell script which runs the original xfce4-session and your logout script if xfce4-session finished.

    # mv /usr/bin/xfce4-session /usr/bin/xfce4-session.orig
    

    The new /usr/bin/xfce4-session file:

    #!/bin/bash
    /usr/bin/xfce4-session.orig
    echo "my logout script" > /tmp/testfile
    

    Don't forget to set the execute permissions:

    # chmod a+x /usr/bin/xfce4-session
    

    (Tested on Debian Squeeze.)