I don't actually know why using the XFCE Session and Startup applet to include logout sounds doesn't actually work. What I suspect is that the log out is so fast these days, that XFCE has been killed and control handed over to the Lightdm Desktop Manager before the sound has a chance to play.
Upgreyed came up with an idea which causes the Logout sound to play whenever the LogOut dialogue is run. Which after a few weeks going with it, I find rather irritating. If you run the Logout Dialogue, the logout sound is played even if you cancel the logout, and it's played and done before you log out. All seems odd to me.
However, there is another way! It takes advantage of the fact that, in the $PATH variable, for users (but not for root), /usr/local/bin comes before /usr/bin. The executable file that runs the XFCE desktop is called xfce4-session, and what you have to do is to create a script in /usr/local/bin with the same name, which will be run in preference to the XFCE executable. You have to create a file, in /usr/local/bin/ as root, called xfce4-session. It should be marked as executable.
It reads as follows:
My earlier attempt at this involved renaming the XFCE executable, and putting the script in /usr/bin, obviously the line to call the executable would be different to reflect that. But then I thought: What if there is an update to the XFCE executable? This way we're covered!
Obviously this way also has its disadvantages, in that control cannot be passed to LightDM, or the computer cannot shutdown or reboot, until the sound has finished playing. It's down to personal preference.
Upgreyed came up with an idea which causes the Logout sound to play whenever the LogOut dialogue is run. Which after a few weeks going with it, I find rather irritating. If you run the Logout Dialogue, the logout sound is played even if you cancel the logout, and it's played and done before you log out. All seems odd to me.
However, there is another way! It takes advantage of the fact that, in the $PATH variable, for users (but not for root), /usr/local/bin comes before /usr/bin. The executable file that runs the XFCE desktop is called xfce4-session, and what you have to do is to create a script in /usr/local/bin with the same name, which will be run in preference to the XFCE executable. You have to create a file, in /usr/local/bin/ as root, called xfce4-session. It should be marked as executable.
It reads as follows:
- Code:
#!/bin/bash
# Run xfce then play sound on exit.
# Note that you must include the full path to the XFCE executable, to ensure that
# the script doesn't just keep calling itself!
/usr/bin/xfce4-session
# On exit, play the sound:
play -v 1.0 --magic /usr/share/sounds/`xfconf-query -c xsettings -p /Net/SoundThemeName`/stereo/desktop-logout.*
My earlier attempt at this involved renaming the XFCE executable, and putting the script in /usr/bin, obviously the line to call the executable would be different to reflect that. But then I thought: What if there is an update to the XFCE executable? This way we're covered!
Obviously this way also has its disadvantages, in that control cannot be passed to LightDM, or the computer cannot shutdown or reboot, until the sound has finished playing. It's down to personal preference.