Jinamp Party Piece

Jinamp Party Piece

Ok, daughter having birthday party, kicking us out of the house for the evening. Last year, I set her up with Audacious on the htpc so that she and her guests could chose music to play, with a couple of backup options of using xbmc or a DVD full of mp3s. This year we have a new machine running as htpc, no DVD drive. Also, daughter just wants a shuffled playlist to run, with no intervention.

A few weeks ago I was mooching about on KMandla’s new wiki of CLI apps, and came across jinamp , which is a sort of background player. What it does is takes the feed of a directory or playlist, shuffles it, then sequences it to a player of its or your choice, then disappears off into the background.

So I built up a playlist using audacious, called it pop.m3u and saved it to a shared place on the network. I needed to tidy up this list to just have file paths and names so:

sort pop.m3u > pop.lst

*.lst is the default file format for playlists with jinamp. Next I just opened up pop.lst and deleted all the EXTINF lines, which were now nicely sorted to the top. So now the playlist contents looked like this:


Order doesn’t matter because it is going to get shuffled anyway đŸ˜‰

So downloaded and installed the latest (and pretty old) version of jinamp

sudo dpkg -i jinamp_1.0-1.i386.deb

I also had to install mplayer, as I was going to use this as my player:

sudo apt-get install mplayer

Added just one line to mplayer’s ~/.mplayer/config file for now:


in the hope that this would help to normalise sound levels (seems to do something)

Right ready to test now, here is the basic command to get it running:

jinamp -p /usr/bin/mpayer /path/to/pop.lst

There is a little pause, and then music starts playing, you are back at the command prompt, and can no longer interact with the program. If you look in htop, you will see an entry for jinamp and also one for mplayer playing the file.

I set up the htpc with a fullscreen terminal, which would just serve to confuse (no fiddling) and amaze (how cool and geeky!) 17 year olds :) Had to run this with X, as for some reason I can’t get a VT over hdmi.

But of course you need to be able to interact with jinamp, to stop it (it will just keep on going!) or to skip to the next song. You might also want to display the title and artist of the current playing song as well. This is where jinamp-ctl comes in.

jinamp-ctl stop

will stop the thing running and close the player.

jinamp-ctl next

will move you to the next song on “jinamps” list.

jinamp-ctl query

will show you the name of the currently playing song (along with its full path!)

So I set about figuring out how to start the player, and then show the name of the currently playing song in the middle of the screen, without the mp3 extension, no cursor or mouse cursor, in a lovely cyan colour with a black background. I needed a script!

To remove the terminal cursor you have to type:

setterm -cursor off

To remove the mouse cursor, the easiest solution I found was to install “unclutter” and then run it, removes the idle cursor from the screen after 5 seconds by default. Further usage and investigation shows that unclutter runs at start up so if you like having it in your session, you don’t need the command. If you want to choose when to start unclutter, then edit the /etc/default/unclutter file and change true to false.

sudo apt-get install unclutter


To change the colour of the screen text I needed “tput” which is already installed by default.

tput setaf 6

makes text cyan

tput setab 0

makes the background black (already is but useful to know)

tput bold adds

bold to the text to make it stand out more.
More on this here

Next was to strip the filename back to you the Artist and Title from the output of jinamp-ctl query. I did this by piping jinamp’s output into xargs and basename as follows:

jinamp-ctl query | xargs -0 -n1 -imp3 basename mp3 | cut -d”.”

It took a fair bit of googling to find all the elements required for this :)

Then I needed this output to update regularly. Too tricky for me to figure out what was required when the song actually changed, so I just went for a routine that fired every five seconds:

sleep 5

Finally, the solution to centre the text output on the screen. This takes a bit of trial and error, I am sure it can be figured out programatically rather than adjusting numbers, but for my purposes, this worked. The htpc screen is running at 800×600 (because the htpc is also linked to another older TV that can’t cope with more) so a terminal at full screen has @ 80 columns and 30 lines. I found that:

perl -e ‘print “n”x10’;

added enough blank lines, and then piping all the output through to:

sed  -e :a -e ‘s/^.{1,57}$/ & /;ta’

put the text more or less in the centre. ( I also set terminal font size to 16 ). Life is too short for me to learn and understand sed :)

So the final script called jinamp.sh looks like this:

#! /bin/bash#hides cursor
setterm -cursor off &

#hides mouse cursor after 5 seconds
unclutter & # (only needed if you haven’t rebooted)

#starts jinamp with named playlist

jinamp -p /usr/bin/mplayer “/media/music/burn/pop.lst”

#displays playing file every five seconds when jinamp is running

tput setaf 6;
tput setab 0;
tput bold;
while [ 1 ]; do
jinamp-ctl query | xargs -0 -n1 -imp3 basename mp3 | cut -d”.” -f1 && perl -e ‘print “n”x10’; sleep 5; done | sed  -e :a -e ‘s/^.{1,57}$/ & /;ta’

This is all fine, but daughter might wish to move to the next song. To save her fiddling about at the htpc with wireless mini keyboards and remotes, I simply set her up with a putty ssh session into the htpc so that she could type jinamp-ctl next.

Party is tonight, so we’ll see how well it goes. Had the thing running all morning without a hitch, but will have to write instructions in case of power failure, or some oik unplugs the htpc, etc…..

3 thoughts on “Jinamp Party Piece

  1. Just realised I don’t need to use the unclutter command everytime, as this runs on startup of machine (that’s why i was getting a complaint from unclutter about windows! Just remove that line from the script. I’ll leave it in for first timers.

  2. To stop unclutter starting with X, simply edit the /etc/default/unclutter file and change true to false. Now you can run unclutter with the script if you are doing this in X

Leave a Reply

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