Display VLC Music information in Conky

in #linux6 years ago

Sometimes wanting to do the most simple of things comes in a difficult to do package. I myself have become extremely frustrated, at times, trying to get little things done that, by right, should only take a few minutes, but end up taking hours and hours.

In the spirit of making things easy for the next guy, I spent hours and hours figuring some things out and have decided to post the results so that you can take minutes to do it for yourself. You're welcome.

For starters, you can get the information you desire from VLC with the following terminal command:

qdbus org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Metadata

You can dump this information into a file by using the following terminal command (just replace "path" and "file" with the path and filename you want the information dumped into):

qdbus org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Metadata > /path/file

From here, you can look and see what all VLC has to offer. To place this information into Conky, I would begin by writing a script file. For the sake of this tutorial, let's call it "vlc.sh".

The contents of vlc.sh will look like this:

#!/bin/bash

qdbus org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Metadata > /tmp/vlc

qdbus org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Metadata | grep artUrl | cut -c22- | awk '{gsub(/%20/," ")}1' >/tmp/album2

echo "$(cat /tmp/album2)" >/tmp/art2
ln -sf "$(cat /tmp/art2)" /tmp/album2.jpg

exit 0

#End of Script

This is what the script does: It will fetch the VLC information and dump it into a file called "vlc" in your /tmp/ folder. It will also take the art url of the music file and will place it in a file called "art2" in your /tmp/ folder. It will then take the information from the "art2" file and create a symbolic link which will display the current album art.

Note: VLC uses %20 instead of a space in the Art and File URL's. The album art will not be found with the formatting VLC uses, and so the script file changes %20 to an actual space when it dumps the information into the "art2" file.

Note 2: I use "art2", "album2", etc. in case you also use CMUS and want to display music information for both in Conky (refer to my previous post here (https://steemit.com/linux/@patranella/expanding-on-linux).

In your .conkyrc file, you have to place the following information to display your VLC data in Conky (refer also to my previous post here (https://steemit.com/linux/@patranella/expanding-on-linux):

#VLC Music:
"Backslash" (Use an actual backslash. I had to write the word instead of the symbol so Steemit would show it properly)
${if_running vlc}
${execi 5 sh ~/Path/Folder/vlc.sh}
${image /tmp/album2.jpg -n -p 0,160 -s 140x140}

${execi 5 qdbus org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Metadata | grep artist | cut -c15-}
${execi 5 qdbus org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Metadata | grep album | cut -c14-}
${execi 5 qdbus org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Metadata | grep title | cut -c14-}
${endif}
"Backslash" (Use an actual backslash. I had to write the word instead of the symbol so Steemit would show it properly)

What this information does, is it provides space for the album art and shows the artist, album, and song title. You will have to show the proper path to the "vlc.sh" file, and alter the coordinates and size of the album art to suit your needs.

Hopefully, with only a few personal adjustments being needed from you, I have made it easy for you to incorporate VLC into your Conky experience.

Sort:  

Congratulations @patranella! You have received a personal award!

1 Year on Steemit
Click on the badge to view your Board of Honor.

Do not miss the last post from @steemitboard:

SteemFest3 and SteemitBoard - Meet the Steemians Contest

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @patranella! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Do not miss the last post from @steemitboard:

SteemFest Meet The Stemians Contest - The mysterious rule revealed
SteemFest⁴ - Meet the Steemians Contest
Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Coin Marketplace

STEEM 0.19
TRX 0.15
JST 0.029
BTC 63098.94
ETH 2621.87
USDT 1.00
SBD 2.74