How to run logout script or sound on Linux XFCE

Most of you would know how to run script on boot / session login on Linux, but not on logout / shut-down. Here is one way you can do it:

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
aplay /home/yourusername/logoutsound.wav

Don’t forget to set the execute permissions:

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

Tested on Arch Linux
Reference: http://stackoverflow.com/questions/7579438/how-to-execute-a-script-when-xfce-session-ends

(Visited 1,658 times, 1 visits today)