|
11 years ago 7 |
This is a tutorial to set up a script that turns the volume up to awake-volume at awake-hour, and turns it down to sleep-volume at sleep-hour automatically.
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:
#!/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
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!