How to make Shutdown/Reboot sound play until the end?

Is there a way to make the shutdown sound play full length of the file, and is there a way to make it play when shutting down/rebooting via terminal command?

I use cvlc in order to make the sound play. Startup melody plays as intended, but if I click “Shutdown” or “Reboot”, the melody plays only for a second or so, before completing the above mentioned action. Plus, if shutting down via command, there is no sound at all.

It is not that big of a deal, but it would be great to find the way to implement this customization. I used to have the same issue back on KDE and decided that I don’t care that much. Just so happens that now I have some spare time to tinker with it. Any ideas or suggestions?

When you shut down or reboot through the GUI, your system kicks off a shutdown sequence that terminates processes, including the audio playback process (cvlc), before the sound can finish. That’s why your melody only plays for a second or so.

Desktop environments like GNOME, KDE, or XFCE typically stop audio services, such as PulseAudio or PipeWire, early in the shutdown process, which interrupts your sound.

When you use terminal commands like shutdown, reboot, or poweroff, they don’t trigger the same scripts or hooks as GUI shutdowns.

1 Like

Thank you for the information. I guess there’s no point in trying to make the shutdown sound play when turning off via command then. However I wonder if there’s a way to make it so that the process termination sequence doesn’t proceed before the tune has played entire file first.

Possible? Absolutely. Worth the effort? Depends on whom you ask.

I personally wouldn’t bother.

In xfce startup settings you can add a script that plays your sound. You can choose when this event will be triggerd (on shutdown or logout etc) just click on trigger
I’m not sure how this works but it implies that the sound would be played before logout or shutdown is suppose

I’ve already done that. It just doesn’t play entire melody before shutting down or rebooting. You can just hear a few first notes of the tune and the computer is already off.

You have a fast machine lol not the audio file’s lengths fault it shuts down before the tune ends :hugs:

I use a script as startup sound maybe you can do the same with something that force to wait until the srcipt is finished?
Not sure how

#!/bin/bash
play /usr/share/sounds/Smooth/stereo/desktop-login.oga > /dev/null 2>&1

the /dev/null is to prevent xsession to flood with messages from play

Yep, this one is still comparatively new. I get it that it’s not about the file’s length or anything :slightly_smiling_face:

Yes, I think I am looking for a way to implement exactly this, but neither do I know about how it can be done.

Would this help

or this

To play the tune during shutdown this might help you.
https://unix.stackexchange.com/questions/39226/how-to-run-a-script-with-systemd-right-before-shutdown

It recommend to create a systemd unit. See the link for explanation.

[Unit]
Description=...

[Service]
Type=oneshot
RemainAfterExit=true
ExecStop=<your script/program>

[Install]
WantedBy=multi-user.target

Basicaly you create a systemd unit which run an action during its shutdown.
It may also be necessary to add Requires= in the [Unit] section with sound.target so that the sound is not disabled before it plays the tune. But I am not sure if that is the correct way.
Also you will delay the shutdown.

It is a strange thing to see that someone wants to play all kind of sound during booting and shutdown. Feels like 1990s to me. :grin:

haha i even have sound effects on workspace switching, usb plug/unplug and login