[FIXED]Shutdown sound with aplay

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Riboshom

[FIXED]Shutdown sound with aplay

Post by Riboshom »

Hello Mint community!
I've been trying for a few hours to install a custom shut-down sound (that was quite hard, btw, I'm surprised that there's no application for that yet!) and I'm currently stuck.
As most of you probably know (or not, there's a first time for everything), mint currently have a glitch that prevents it to play it's shutdown sound properly since it uses pulseaudio to do so and that, as the shutdown routine is curently set, it is killed before it had the time to even start playing it. So I decided to work arround it and use aplay instead, but...
I can't find any way to set the "Quit..." menu to follow a custom routine without totally breaking my computer (sure, using a shell script instead of shutdown may seem like a clever idea at first, but if it doesn't take arguments, it might end up causing a lot of trouble just to get a lil chime on shutdown)

So if anyone here can help me (googling gave nothing good), I'd be quite thankful!
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
Pilosopong Tasyo
Level 6
Level 6
Posts: 1432
Joined: Mon Jun 22, 2009 3:26 am
Location: Philippines

Re: Shutdown sound with aplay

Post by Pilosopong Tasyo »

o Give a man a fish and he will eat for a day. Teach him how to fish and he will eat for a lifetime!
o If an issue has been fixed, please edit your first post and add the word [SOLVED].
Riboshom

Re: Shutdown sound with aplay

Post by Riboshom »

Oh thanks, I'll try this out! :D
Riboshom

Re: Shutdown sound with aplay

Post by Riboshom »

Allright, so what I should do is:

1. sudo gedit /etc/init.d/aplay
2. ????
3. ln -s /etc/rc0.d/S10aplay /etc/init.d/aplay
4. chmod 755 /etc/init.d/aplay
5. PROFIT?

I'm really not sure how I should arrange that script.
It looks really dangerous to do that when you're fairly novice at bash scripting like I am (chaining commands is still allright, but making complete scripts that supports arguments and stuff is a no-go)

I'm just trying to execute "aplay /home/user/foo/shutdown.wav" right when the shutdown sequence starts while refraining it from going further before aplay is done executing.
User avatar
Pilosopong Tasyo
Level 6
Level 6
Posts: 1432
Joined: Mon Jun 22, 2009 3:26 am
Location: Philippines

Re: Shutdown sound with aplay

Post by Pilosopong Tasyo »

1. sudo gedit /etc/init.d/aplay
First, gedit is a GUI-based text editor. In lieu of sudo (which is used for non-GUI commands), use gksudo. Second, I'd suggest you use a less ambiguous shell script name. There's already an aplay command located in /usr/bin. So, instead of /etc/init.d/aplay, use /etc/init.d/myshutdownwav, for example.
2. ????
Let's keep it simple. The content of the myshutdownwav script would be something like the following:

Code: Select all

#!/bin/sh
aplay /home/user/foo/shutdown.wav
3. ln -s /etc/rc0.d/S10aplay /etc/init.d/aplay
I believe the proper way to install this script is to use the update-rc.d command. But for a quick and dirty fix, creating a symlink does the job as well. Now, instead of S10, use K10 or a lower number. What's important is (the symlink to) myshutdownwav script gets called ahead of other scripts in the rc0.d folder. On my end, the first symlinked script in the rc0.d folder is K20hddtemp. K10myshutdownwav looks like a good candidate.
4. chmod 755 /etc/init.d/aplay
Don't forget to put sudo before chmod, and change /etc/init.d/aplay to a less ambiguous filename.
5. PROFIT?
Ok you got me here. I don't get what you meant by 'profit.' But if all goes well, the changes will take effect immediately. At this point, shutdown the computer to test it for yourself.

Before I wrote this reply, I did a test with a 44-second wav file. I shutdown the computer and it played the whole 44 seconds without any cuts. It works as intended.

HTH and good luck.
o Give a man a fish and he will eat for a day. Teach him how to fish and he will eat for a lifetime!
o If an issue has been fixed, please edit your first post and add the word [SOLVED].
Riboshom

Re: Shutdown sound with aplay

Post by Riboshom »

Pilosopong Tasyo wrote: gksudo gedit /etc/init.d/shutdownsound

Code: Select all

#!/bin/sh
aplay /home/user/foo/shutdown.wav
ln -s /etc/init.d/shutdownsound /etc/rc0.d/K10aplay
sudo ln -s /etc/init.d/shutdownsound /etc/rc0.d/K10aplay
sudo chmod 755 /etc/init.d/shutdownsound
Allright, thank you very much! I appreciate that you took the time to test the script on your own computer before posting.
Pilosopong Tasyo wrote:
5. PROFIT?
Ok you got me here. I don't get what you meant by 'profit.
It's from South Park I think, it's just a very popular twist that's often added in a series of steps that don't go anywhere.

EDIT:
Why can't the actual distro have this?
Have they planned to fix this issue?
Locked

Return to “Software & Applications”