Topic: How To: moc & conky - correct filenames (no id3)
just wanted to share a little tip i have for using MOC with conky.
if you are like me and you hate ID3 tags and just spend hours of your life making sure all your filenames are in order, you don't want to use the ${moc_artist/album/title} options from conky. a 2nd reason for not wanting this is because (afaik) there is no ${moc_number} option to display the position of the song on the album.
so, you want to use the ${moc_file} option, but it gives you the full path to your song. it needs to be trimmed.
i just spent the last hour figuring out how 'sed' works for this so you don't have to. add this line to your conky to show the filename of whatever you're playing in moc without the whole path and without the file-extension:
${if_running mocp}${exec mocp -Q %file | sed -e 's_/.*/__' -e 's_\..\{3\}$__' -e 's/_/ /g'} :: ${exec mocp -Q %tl} / ${exec mocp -Q %tt} [ ${exec mocp -Q %state} ] $endiftranslation:
${exec mocp -Q %file} < do 'man moc' for details, this gives you the filename, same as ${moc_file}
sed -e 's_/.*/__' < sed: strip everything between the first and last forward slash, leaving you with just the filename
-e 's_\..\{3\}$__'} < sed continued: strip everything with '.blahblablah' from the end of the line
-e 's/_/ /g' < sed continued: display underscores as spaces
(used the _ as a delimiter in sed as to not get a big mess of slashes)
hope this is of any use to anyone :)
edit: made some changes. above code now also includes other stuff like moc time left and total time and moc state. see a couple posts below to see description of changes.
Last edited by rhowaldt (2011-09-07 14:04:01)