tune

Command-line interface for iTunes.

macOS ScriptingBridge Swift

Screenshot of tune

Many times while at work, or while managing one of my VPS machines, I felt like I wanted to play some specific song from my iTunes library. But because I had my screen covered with several terminal sessions, many times in full-screen, it felt more like breaking my workflow than anything else.

So in a reversal of what I did with Cakebrew, I wrote a command-line tool to control a graphical application. Because ScriptingBridge, a fantastic feature from the heydays of Mac OS X, is still present in macOS, this was as easy as it can be. A simple programming interface is auto-generated, to which you can link and build code that sends and receives information from other applications.

A first version was a simple command line input-output program, with at most a single prompt in case your query produced more than one relevant result. Later I rewrote almost the entire thing to have a prettier text interface, using ncurses.

Now that macOS has Siri, this has become less of a problem, as I can ask Siri to play a specific song for me. However the fun in creating a project in ncurses for the first time made it still worth it.