i3status with media info and last post from RSS

Joaquin L. Pereyra
Avalanche of Sheep
Published in
2 min readFeb 25, 2015

You might remember this post, where I published a little script to show the data from cmus in your i3status line. Well, I have expanded upon that a little bit, resulting in the following code:

#!/bin/sh
# shell script to prepend i3status with more stuff
i3status | while :
do
read line
cmus_status=$(cmus-remote -Q | head -n 1 | cut -d ' ' -f2-) #you should replace with your own settings if you use a different player
if [ "$cmus_status" = "playing" ]; then
artist=$(cmus-remote -Q | grep ' artist ' | cut -d ' ' -f3-) # idem: replace with your own settings if necesarry
song=$(cmus-remote -Q | grep title | cut -d ' ' -f3-) #idem: replace with your own settings if necesarry
echo "$artist - $song | $line" || exit 1
else
lanacion=$(curl http://contenidos.lanacion.com.ar/herramientas/rss/origen=2 --silent | grep '<title>' | head -n2 | tail -n1 | sed -e s/'<title>'//g | sed -e s/'<\/title>'//g) #replace the RSS feed as necesary
if [ ${#lanacion} -gt 0 ]; then
echo "${lanacion::-1} | $line" || echo "" && echo "ERROR" >> ~/.statusbarlog || exit 1 #you should probably delete the ::-1, it is just a little workaround for (I think) a La Nacion-specific problem
else
echo $line || exit 1
fi
fi
done
As you can see, it is not the most beautiful code around, but it does it's job. Basically, if you are listening to music, it will show artist and song being played. If you are not, it will display the last news from an RSS feed.The comments make clear where you should replace with your own settings.Enjoy!

--

--