Alex van Es
Alex van Es

Reputation: 1181

Write name of current song playing in mpg123 to file

I am coding together a script that will display the current song playing on my Raspberry on a HD44780 display. I got everything working except the part where I need to display the name of the song currently playing.

mpg123 -Z /mnt/usbflash/mp3/*  > /tmp/ramdisk/mpg123.output &

The above command will play the songs just fine, but it doesn't write the track info the the text file.. any ideas what is the best way to script this?

Upvotes: 2

Views: 1095

Answers (1)

tripleee
tripleee

Reputation: 189749

Run on one file at a time in a loop, and keep track of where you are in the loop.

for f in /mnt/usbflash/mp3/*; do
    echo "$f" >/tmp/currently-playing
    mpg123 -Z "$f" # maybe redirect stdout / stderr?
done &

Upvotes: 2

Related Questions