CMus data on i3bar with i3status
Published in
2 min readFeb 17, 2015
Wanna see what song and artist CMus is playing in your i3bar? Although i3status doesn’t support the execution of external scripts, there’s a simple workaround to this: use your own shell to add information to i3status.
This is not hard and with a little tinkering and some shell-foo you can accomplish quite a few things. One of the simplest is showing the output of a command. And guess what: we can use that to display CMus data on the bar.
You can see the result and all the config files involved in the image.
First of all, you should create a script to replace the vanilla i3status. The one I wrote goes like this:
#!/bin/sh
# shell script to prepend i3status with cmus song and artisti3status | while :
do
read line
artist=$(cmus-remote -Q | grep ' artist ' | cut -d ' ' -f3-)
song=$(cmus-remote -Q | grep title | cut -d ' ' -f3-)
echo "$artist - $song $line" || exit 1
doneThe centering is not perfect but it is good enough on my 1920x1080 monitor. You may need to adjust the blank spaces on line 9 for your resolution.It is easy to see how you can modify the script to make it display any CMus data you want. Just explore the output of cmus-remote -Q and see what you find interesting.You should make the script executable and then tell i3 you want to use it. For this, most probably you'll have to go to ~/.i3/config and change this section:# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
bar {
#status_command i3status
status_command ~/.statusbar/mystatus.sh #new status command
mode dock
position top
}If for some reason you want to change back, just uncomment the first line after bar and comment the second one.