Skip to content

Instantly share code, notes, and snippets.

@heptal
Last active January 16, 2020 21:51
Show Gist options
  • Save heptal/b15d5d91623d0a58a1638deb8c23c094 to your computer and use it in GitHub Desktop.
Save heptal/b15d5d91623d0a58a1638deb8c23c094 to your computer and use it in GitHub Desktop.

I recently discovered mpd and found it to be a nice little program. There is a dearth of nice-looking OSX clients, though (besides terminal clients).

Using the hs.socket extension (in master, but not yet in the latest official release), I've created a Hammerspoon frontend that speaks the mpd protocol. With what I have so far, it's already much faster and easier to use than iTunes. I'll link the code on the Hammerspoon wiki once everything is finalized, but an in-progress version is available here.

Using hs.menubar, I've created a series of menubar items to assist with controlling playback. Hovering over the play/pause icon shows the current track. Hovering over the next icon shows the next track in the playlist:

The icons are defined with ASCIImage which work seamlessly anywhere in Hammerspoon:

icon.next = [[ASCII:  
..................  
..1.......6.......  
..................  
..................  
..................  
..................  
.......3.......8..  
..................  
..................  
..................  
..................  
..2.......7.......  
..................  
]]

More options are in the 🎵 icon (just hs.menubar:setTitle("🎵")). Easy selection of internet radio stations, for one:

Song changes are announced with hs.notify:

Using hs.chooser:queryChangedCallback, I send a search command to mpd and parse the results into a chooser list. Selecting an item adds it to the current playlist and immediately plays it. Searching across the whole database (currently about 7000 songs, still in the process of migrating a bunch of music using beets) is no problem at all. A recent addition to hs.image allows extraction of album art from media files:

https://my.mixtape.moe/xiwknf.mp4

I have another hs.chooser that filters album names. Selecting one enqueues the whole album onto the current playlist:

https://my.mixtape.moe/hepszk.mp4

Another similar hs.chooser allows navigation and selection of the current playlist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment