For the last few months I'd been using Cantata as my mpd client despite the fact it's pretty much been abandoned. Wanting to break away from that, I went in search of some other clients that are still actively maintained. rmpc wasn't what I was looking for; but I liked it. But the one thing I didn't like was having it be just another tab or grouped with all my other Konsole apps.
I did this in alacritty...because at the time I wasn't using it for anything else and could just mess with it's global config all I wanted. In production...you probably want to make a seperate config file for whatever you're using. I also don't know what options you'll need to change...so hopefully you can keep up.
alacritty.toml
[window.class]
instance = "rmpc"
general = "rmpc"
We don't want this grouped with our other terminals; and we also want it to be able to get proper icons and stuff. How you set the window class in your terminal is something you'll have to man up. Now we need to make a .desktop file to bring this in to Plasma:
[Desktop Entry]
Name=rmpc
GenericName=Music Player Client
Comment=Play music in MPD from your terminal.
Exec=alacritty -e bash --noprofile --norc -c '/home/user/rmpc.sh & rmpc'
Icon=mpd
Terminal=false
Type=Application
Categories=AudioVideo;Player;ConsoleOnly;
StartupWMClass=rmpc
You're probably asking about rmpc.sh; well I will tell you about that. You're going to be making it next, so just set that to wherever you'll put it. Feel free to customize the icon. I chose the mpd icon because I liked it.
update-desktop-database ~/.local/share/applications/ (or wherever you stored the .desktop) and we're almost ready to go. Remember that shell script you called but doesn't exist? Now we're going to create it.
#!/bin/bash
windowtitle() {
title=$(mpc --format "%title%" current | sed -E 's/^(2CH|MCH) - //; s/^[0-9]{2} - //' | awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) tolower(substr($i,2));}1')
artist=$(mpc --format "%artist%" current | awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) tolower(substr($i,2));}1')
status=$(mpc status | awk 'NR==2 { print $1 }' | tr -d '[]')
[[ -z "$status" ]] && echo -ne "\033]0;rmpc - Not Playing\a" || echo -ne "\033]0;rmpc $status: $artist - $title\a"
}
# Initialize title
windowtitle
# watches for trigger to update things
mpc idleloop player | while read -r event; do
windowtitle
done
This is the script that runs in the background that updates the window title. Yes, literally. Puts the artist and track title as the window title. The sed statement on title is to filter the 2CH and MCH prefix added by the sacd patch.