I've found similar problems on stackexchange, but never close enough to my case to help.
I'm trying to create a script and bind it to a key, so that when pressed, it displays "title
by artist
" OR, if there is no artist/title, it displays "filename
".
Cmus (my music player of choice) has cmus-remote
paired with the -C
(raw) option which let me query cmus player for anything and get a newline-separated response like:
cmus-remote -C 'format_print %a %t %F'
Beach House
Space Song
/home/user/Music/Beach House - Space Song.mp3
The thing is, I don't want to run cmus-remote
for each of the queries and instead would prefer
IFS= read -r artist title file << EOF
$(cmus-remote -C 'format_print %a %t %F')
EOF
However that only provides artist
and title
and file
are empty
Note: removing the -r
option doesn't help in this case, nor does modifying IFS
.
To elaborate: my Music folder isn't fully tagged, i.e. some songs don't have an artist or title, so the idea of this script is on exec to send a notification 'playing title
by artist
', if there's no title or artist 'playing filename
' so I kindof need to have the three variables to then evaluate wich notification to send.
while
finishes, is that really all you need? If so, please let me know and I will udnelete your answer with my apologies. – terdon May 15 '23 at 13:44if a and t else f
inside the loop is just fine for what I'm trying to do – Dr. Coomer May 15 '23 at 14:37