From Music Player Daemon Community Wiki
- Description: Small bash script to log tracks played with MPD to a plain text file. It is very simple and customizable being under 20 lines of code. It depends on mpc. This has been supplanted in the author's case by using ncmcpp and the on song change ability. It's still useful for ideas, I suppose, or if you use mpc and not ncmpcpp.
- Homepage: MorskNorsk.mine.nu:666/~mordbrann/ampdlogger
- Maintainer(s): Unknown
#!/bin/bash
path="$HOME" #path to write out files
delimiter="║" #used to seperate time and track info - other suggestions: ‣ ✠⯠♥
polltime=1 #how often to poll in seconds
previous=$RANDOM
while true
do
OF=Playlist-$(date +%Y%m%d) #filename format, placed here so it changes when date changes
song=`mpc --format "%artist% #» %album% #» %track% #» %title% #» %time%" |grep »`
sleep $polltime
if [ "$song" != "$previous" ]; then
if [ -n "$song" ]; then
echo $(date +%H:%M:%S) $delimiter "$song" >> $OF
previous="$song"
fi
fi
done