New Found Love for AppleScript

I recently purchased a new computer and set it up as my always-on home-theater/media machine. One of the tasks it performs for me is serving as my morning alarm clock through the use of an application called Alarm Clock Pro. This handy tool allows me to set repeating alarms that can perform a variety of tasks on my computer.

For some time I’ve envisioned a scenario where I could awaken in the morning to a randomly selected episode of The Simpsons. Today, that dream has become reality. 😀

Using Alarm Clock Pro, I can trigger an “AppleScript”. AppleScript is a programming language with a very high human readability- it looks as if it is pseudo-code. I knew very little about it, other than the fact that existed. After a little googling and a couple evenings of tinkering, I have created a script that is capable of selecting a random episode out of a random season of my folder designated as “The Simpsons”. The script then triggers the application VLC via command-line to play the selected episode, skip 1:00 into it (It wouldn’t be quite as fun to wake up to the theme song every morning).

On top of all that, the AppleScript also can slowly fade the volume in! Fading volume provides for a much more comfortable wake-up than an instant surprise. There was a hurdle to get over with this- Once the shell command to launch VLC was called, it would block activity on the thread until VLC had completed and exited. Thus, the volume would not fade in for the episode. I was able to solve this issue by triggering the VLC command on a background thread.

It would be easy to modify this script to select a different show, or randomly select any media file within a directory. Currently it is coded to search one specified directory (the show), then select a random folder within it (the season), and then select a random media file within that (the episode).

To download the applescript (text form) click here.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *