My computer speakers make a horrible sound while shutting down and I keep forgetting to turn them off before shutdown. I would like to prevent this with a "just in time" reminder. Something like a popup window that also delays shut down until I click a confirmation button would be great.
-
Standard Ubuntu and most of the derivatives with other DEs already do that by default. – Aug 17 '17 at 08:34
-
By "horrible sound" do you mean PC Speaker Beep? If so this might help: https://askubuntu.com/questions/829258/turn-off-motherboard-pc-speaker-beep-in-ubuntu-16-04-regression – WinEunuuchs2Unix Aug 17 '17 at 11:03
2 Answers
To display a message before halting, just follow these steps:
Write a script containing the commands you want to be executed, e. g.:
#!/bin/bash # for zenity it might be necessary to set the DISPLAY variable first with the following line: # DISPLAY=":0.0" zenity --warning
save the script wherever you want, I use
~/scripts/myscript
as an example heremake it executable with
sudo chmod +x ~/scripts/myscript
link it to the shutdown directory using
sudo ln -s ~/scripts/myscript /etc/rc0.d/k01zenitywarning
The script will be executed the next time you shut down. To execute it alsoon reboot, additionally link it to /etc/rc6.d/
with sudo ln -s ~/scripts/myscript /etc/rc6.d/k01zenitywarning
.
This does what you asked for, however I also really like omid abc's approach to solve the problem – instead of manually turn off the speakers every time just mute the sound using his command (replace the zenity
line in the script for that).
Edit – simpler approach
An even simpler way is provided by the upstart
package, after installing it just save the following script in ~/.init/onshutdown.conf
start on starting rc RUNLEVEL=0
task
script
# for zenity it might be necessary to set the DISPLAY variable first with the following line:
# DISPLAY=":0.0"
zenity --warning
end script
Again, zenity --warning
can be replaced by any command(s). This script doesn't need to be made executable, just save it and you're done. For more information about upstart
see man 5 init.
-
1I think you need to set the
DISPLAY
environment variable if you want to use Zenity from anrc.*
script. – David Foerster Aug 18 '17 at 11:56
A solution for your problem is to mute volume before shut down.
Write this script in /etc/rc0.d
:
#!/bin/bash
amixer set Master mute
be sure to make this script executable by using sudo chmod +x myscript
Note that the script is directory will be executed in alphabetical order.the name of your script must begin with k99
to run at a right time
By using this solution when you shoutdown your system it will automatically mute volume

- 431