A program to switch off automatically the sound at certain times (like at night)

elstellino
  7 years ago
  6
  Considered

Well, as the title says..
I have the experience that my wife always forgets the sound of her laptop on, she has to keep it working during the night because in this way she can get financial news from the platform she is working with; every time I am the one who has to go and turn the sound off at 4 am or something.

Well, if there was a program in which one could set the computer in mute mode say at midnight, and restoring the volume levels at say 8 am, that would be brilliant.

Perhaps it could be implemented in Sounds so it wouldn't be that difficult for a user to find it out, and to use it.

What do you think guys?
Latest comments
easy 7 years ago

I've also poste it here: http://community.linuxmint.com/tutorial/view/1155
I didn't know before that tutorials section exists! :)


easy 7 years ago

Hello guys, I've made you a script to do that! :)

It should be run every hour (automated, see below) and it checks if it's awake-hour or sleep-hour and sets the volume accordingly. It'll check if the current hour is exatly the given awake-hour or sleep-hour, and it'll set the volume to the given awake-volume or sleep-volume. The reason I've made it this way is because otherwise it could be really annoying: imagine you're watching a movie, and it sets the volume to 50% every hour. So I've avoided this situation. :)

This is how you can set it up:

1. You need to have 'amixer'. Just open a terminal and type 'amixer' without the quotes of course. If it writes out data then it's okay. If you don't have it installed, type 'sudo apt-get install amixer'.

2. Next thing is to create the script itself. Open gedit and copy-paste the following script. Change 'awake_hour' value to the desired hour (0-24) from when it should be loud. Set 'awake_volume' too (it's the percentage of the volume). Set the 'sleep_hour' and 'sleep_volume' in the similar way.

#!/bin/bash
# Turns the volume down once at sleep-hour,
# and turns it back up once at awake-hour.
echo "Volume manager"

current_hour=`date +%H`
awake_hour=9
sleep_hour=22
awake_volume=70
sleep_volume=30

if (( "$current_hour" == "$awake_hour" )); then
echo "Turning volume up..."
amixer set Master $awake_volume
elif (( "$current_hour" == "$sleep_hour" )); then
echo "Turning volume down..."
amixer set Master $sleep_volume
else
echo "Doing nothing."
fi

3. Save it as 'volumemanager.sh' into your home directory!

4. Now we make it executable. Open a terminal and type 'chmod +x ~/volumemanager.sh'.

5. Now we automate it to run it every hour. Open a terminal and type 'crontab -e'. It might ask you which editor you want to use, choose 'Nano'. Now go all the way down with your cursor and write the following to the last empty line: '0 * * * * ~/volumemanager.sh'. Then press CTRL-X to quit and save it.

6. To check if the crontab is set up, type 'crontab -l'. It should echo what we have just done.

Well done, you've set it up! From now on, on hourly basis the script will run, and it'll turn down/up your volume automatically as you wish. You can alter the hour and volume settings any time by editing the script.

(...If you want to undo the whole thing, just use 'crontab -e', and delete the last line. Save and exit.)

Also it was a great excersise for me to learn a little bash scripting!

Cheers,
easy

P.S. Let me know if there is any problems!


remoulder 7 years ago

Mint is not an application software developer


crismblog 7 years ago

promote the idea


biofool 7 years ago

Easy to implement.


quake0 7 years ago

I like the idea, but I don't think mint team should handle this unless their is nothing else to work on.