If you’re like me, (which you’re probably not…) you enjoy listening to your music with the great music playing daemon known as mpd. You also have your entire collection on shuffle.

Occasionally, I’ll fall into a valley of bad music and end up hitting next far too much to get to a good song. For this reason, I wrote goodsong.

What is it?

Essentially, you press one key command to say the currently playing song is good; then press a different key to say play me a good song.

Goodsong accomplishes exactly that. It creates a playlist file which you can auto-magically add the currently playing song to with the command goodsong. Subsequently, running goodsong -p will play a random track from that same list.

Here’s the --help:

usage: goodsong [ -p | -ls ]

options:
      -p,--play   play a random good song
      -ls,--list  print your list with music dir prepended

      none        note the currently playing song as good

Installation

Goodsong is available in its current form in my git repo.

Usage

Using goodsong is easy. You can always just run it from CLI, but I find it’s best when bound to keys. I’ll leave the method for that up to you; xbindkeys is a nice WM-agnostic way to bind some keys, or you can use your a WM-specific configuration to do so.

Personally, I keep Alt-g as goodsong and Alt-Shift-g as goodsong -p.

You’re going to have to spend some time logging songs as “good” before the -p option becomes useful.

I recently received a patch from a reader for this script. It adds a few features which I’ve happily merged in.

  • Various methods are employed to try and determine exactly what mpd.conf you’re currently running with at the time
  • The goodsong list is now a legitimate playlist file stored in your playlist_directory as specified in mpd.conf

Comments

Showing 5 comments:

on Oct 28, oceans11 wrote:

It says to me: “error: unable to access a playlist file” From what I can understand, touch call in set_playlist() return 1, maybe because of the " around the path (i.e. “/home/oceans11/playlist”/goodsong.m3u )

on Nov 1, pbrisbin wrote:

I’m sorry for that. Before I guess at the problem, can you remove the &>/dev/null from line 66 so that the error message from touch is reported?

on Nov 1, oceans11 wrote:

This is the output: touch: impossibile fare touch di “"/home/oceans11/playlists"/goodsongs.m3u”: File o directory non esistente error: unable to access a playlist file

I also put an echo after the read on line 61: “/home/oceans11/playlists” (with quotation marks)

Thanks for support.

on Nov 1, oceans11 wrote:

Sorry but I used the wrong tag. The right error message from touch is touch: impossibile fare touch di “"/home/oceans11/playlists"/goodsongs.m3u”: File o directory non esistente

on Nov 4, pbrisbin wrote:

It’s tough considering it’s non-english, but I’m assuming /home/oceans11/playlists doesn’t actually exist does it?

You’ll need to mkdir it if you want to use it as your mpd playlists directory (which goodsong will also use)

Please log in to post a comment.

XMonad's IM Layout