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! :)
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.
# Turns the volume down once at sleep-hour,
# and turns it back up once at awake-hour.
echo "Volume manager"
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
echo "Doing nothing."
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!
P.S. Let me know if there is any problems!
Mint is not an application software developer
promote the idea
Easy to implement.
I like the idea, but I don't think mint team should handle this unless their is nothing else to work on.