ArchLabs Linux

Cmus song title in polybar

I love cmus and it provides a cool way to get a notification through a third party command .
To enable this feature in cmus just tupe in the command field:

:set status_display_program=YourSciptName

then press enter. Now let’s build our polybar ipc module because we’re going to use the hook function
of polybar witch is better than some silly interval that might heat the cpu’s.
But before we have to provide this in the master.conf, section [bar/master]

enable-ipc = true

Now edit the module.conf file:

type = custom/ipc
hook-0 = cat $HOME/.config/cmus/cmus_output
initial = 1
format-prefix = "CMUS: "
format-prefix-foreground = ${}
click-right = cmus-remote -s
click-left = cmus-remote -p

And then create a script that will send an hook to polybar telling "please update the [module/cmus]


# Define the output file path & name

# cmus loop
while test $# -ge 2
  eval _$1='$2'

echo "$_title - $_artist" > "$opFile"

sleep 0.2

# This sends a polybar hook to execute
# hook-0
polybar-msg hook cmus 1 >/dev/null 2>&1 &

Thx for sharing, great config in there @archus

You’re welcome

Epic work! If only I used cmus!

hey @Dobbie03 if you run mpd & ncmpcpp you can still use the same cmus module without adding any more module in the bar.
In your ncmpcpp/config enable that line and at the end add a new script name (eg: mpd_status)

execute_on_player_state_change = "mpc --format %title% current > $HOME/.config/cmus/cmus_output && mpd_status"

of course edit as you like and your directories’ tree, then edit a little script mpd_status

polybar-msg hook cmus 1 >/dev/null 2>&1 &

Works fine here so I can switch easy but I know you’re clever enough to find your way to use only mpd with hook module feature. :laughing:

Epic, thank you. Will try it out one of these days.