09.05
A while ago I learned you can set Mac OS X’s volume from cli, so I came up with a way to wake me up.
It starts based on crontab, but mpg123 does a lot of work. Basically I make an Applescript call that will whisper (before waking me up in a big fanfare) that I will be called soon, with a mild volume and OS X’s whispering voice. Then mpg123 does it’s magic: starts playing the mp3 loops I’ve downloaded within an interval of 8 minutes. Actually, it is pretty effective.
So, all you have to do is add the following line to your crontab. To do so, load up Terminal and type in “crontab -e”; then just paste the line below (obviously changing the paths as needed):
40 8 * * 1,2,3,4,5 osascript -e "set volume output volume 50"; /usr/bin/say -v Whisper "Wake up! Alarm will start in 8 minutes."; /usr/local/bin/mpg123 -D 490 -z $HOME/Documents/Coding/Scripts/Alarm/mp3/*;
If you do not understand how cron jobs are set, basically the line above says “at the 40th minute of the 8th hour of days 1, 2, 3, 4 and 5 of the week, run the following command”. The command line is separated in 3 parts:
1) osascript -e “set volume output volume 50″ – as you may have figured, it sets OS X’s main volume to 50% of the total;
2) /usr/bin/say -v Whisper “Wake up! Alarm will start in 8 minutes.” – also, clear as crystal, calls the say (”voice”) application, sending the text;
3) /usr/local/bin/mpg123 -D 490 -z $HOME/Documents/Coding/Scripts/Alarm/mp3/* - tells mpg123 to run all mp3 inside the specified folder, with an interval of 490 seconds.
One of the most interesting things is that, instead of changing OS X’s volume divided in 16 steps (that’s what you get when using your keyboard), you can actually divide it by 100, a real fine tuning.
So, after all, if you are not into downloading mp3 alarm programs, this might be useful.
