Console Last.fm player: shell-fm

Table of Contents

Configuration
Playlist script

Playlist script

by ross at 03:53:27 on October 19, 2012

I wrote a simple script which adds playlist functionality to shell-fm: switch-station.

Save it as /root/bin/switch-station. Modify host variable in it to match the address on which shell-fm is listening for commands.

# chmod a+x /root/bin/switch-station

Create the playlist (/root/.shell-fm/playlist):

lastfm://globaltags/Rock
lastfm://globaltags/Jazz
lastfm://globaltags/Metal
lastfm://artist/Nightwish/similarartists
lastfm://globaltags/Classic
lastfm://globaltags/Irish%20Folk
lastfm://user/xzzs/loved

Replace xzzs with your last.fm login.

My shell-fm daemon is running as root, so I decided to use root's home for storing status files of the script. Because of that the script must be run via sudo (setup sudoers to run it without password for your user).

Here's how it works (bind the commands to hotkeys):

  • sudo /root/bin/switch-station current
    Starts playing the current item of the playlist
  • sudo /root/bin/switch-station next
    Switches to the next item
  • sudo /root/bin/switch-station prev
    Switches to the previous item

Other hotkeys (replace localhost with the address of shell-fm daemon):

  • echo 'stop' | nc localhost 54311
    Stops playing
  • echo 'love' | nc localhost 54311
    Add currently playing song to favourites (managed by last.fm)
  • echo 'skip' | nc localhost 54311
    Skips the song
  • echo 'ban' | nc localhost 54311
    This song will never be played again

The script can use Festival to say the current station name. Install the talking-script part of the link above to enable this.

 

Comments