Now Playing Conky

Add functionality to your desktop
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
User avatar
Bleys
Level 4
Level 4
Posts: 431
Joined: Wed Apr 20, 2022 4:17 am
Location: Essen, Germany

Re: Now Playing Conky

Post by Bleys »

Change mpris.sh (

Code: Select all

            convert ${COVER#*//} '/tmp/tmp.png'
to

Code: Select all

            convert "${COVER#*//}" '/tmp/tmp.png'
To the part of me about the mpris.sh and "do not change". This is the exception that proves the rule ;)
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Now Playing Conky

Post by Logansfury »

Bleys wrote: Sun Feb 18, 2024 1:42 pm To the part of me about the mpris.sh and "do not change". This is the exception that proves the rule ;)
You may change the rules whenever you wish Oh Learned One.

I have made the edit, and now I have display of album art, however, it is selecting the first avail .jpg and ignoring the song info in which the proper album art is assigned. Here is terminal output:

Code: Select all

logansfury@OptiPlex-5040:~$ qdbus org.mpris.MediaPlayer2.qmmp /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Metadata
mpris:artUrl: file:///home/logansfury/Music/album/KISS - Love Gun.jpg
mpris:length: 280704000
mpris:trackid: 
xesam:album: The Wall
xesam:albumArtist: Pink Floyd
xesam:artist: Pink Floyd
xesam:contentCreated: 1979
xesam:genre: Progressive Rock
xesam:title: Hey You
xesam:trackNumber: 14
xesam:url: file:///home/logansfury/Music/Pink Floyd 14 - Hey You 320.mp3
logansfury@OptiPlex-5040:~$ 
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Now Playing Conky

Post by Logansfury »

When I closed Qmmp, Error text generated in the terminal window:

Code: Select all

conky: desktop window (2400010) is subwindow of root window (6cb)
conky: window type - normal
conky: drawing to created window (0x7000001)
conky: drawing to double buffer
Cannot find 'org.freedesktop.DBus.Properties.Get' in object /org/mpris/MediaPlayer2 at org.mpris.MediaPlayer2.qmmp
Cannot find 'org.freedesktop.DBus.Properties.Get' in object /org/mpris/MediaPlayer2 at org.mpris.MediaPlayer2.qmmp
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Bleys
Level 4
Level 4
Posts: 431
Joined: Wed Apr 20, 2022 4:17 am
Location: Essen, Germany

Re: Now Playing Conky

Post by Bleys »

shouldn't actually happen. I test with ps if the player is running before the sh script is executed.
Possibly a timing problem.
Works here without any problems.

About the cover selection. I am not aware of any player that would look into an info file.
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Now Playing Conky

Post by Logansfury »

AHA!!!

OK I don't know what the problem is on my system, but I just switched players from qmmp to audacious, made sure mpris was enabled in audacious preferences, and fired up a KISS then Pink Floyd file in sequence and it displayed the correct album art for each song :)

I don't know why VLC and Qmmp aren't full function with this conky, but I'll just stick with Audacious player.
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Bleys
Level 4
Level 4
Posts: 431
Joined: Wed Apr 20, 2022 4:17 am
Location: Essen, Germany

Re: Now Playing Conky

Post by Bleys »

Customized Conky for Cinnamon Applet Radio++
Screen Capture_select-area_20240219093842.jpg
Screen Capture_select-area_20240219094358.jpg
Screen Capture_select-area_20240219094358.jpg (8.72 KiB) Viewed 504 times
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Now Playing Conky

Post by Logansfury »

Bleys wrote: Mon Feb 19, 2024 4:41 am Customized Conky for Cinnamon Applet Radio++

Screen Capture_select-area_20240219093842.jpg

Screen Capture_select-area_20240219094358.jpg
Very Cool!

This Radio++ is nifty. The Classics stations I am finding are playing a lot of less known songs from popular artists that never made it to radio play here in the States.
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Now Playing Conky

Post by Logansfury »

Bleys, when you have time may I make a customization request?

I would love to see a display of Album name in between the displayed Artist Name and Song Title.

Would this be difficult?
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Bleys
Level 4
Level 4
Posts: 431
Joined: Wed Apr 20, 2022 4:17 am
Location: Essen, Germany

Re: Now Playing Conky

Post by Bleys »

Logansfury wrote: Mon Feb 19, 2024 4:21 pm Would this be difficult?
Not at all ;)
Screen Capture_select-area_20240219233006.png
Screen Capture_select-area_20240219233006.png (100.1 KiB) Viewed 456 times
mpris.sh:

Code: Select all

#!/bin/bash
#
# Bleys 2023
# dependencies: urlencode, qdbus
# sudo apt install gridsite-client qdbus
#
#
Player=$1

if [ $(ps -C $Player -o pid=) ]; then
convertsec() 
	{
	    x=`expr $1 / 1000000`
	    s=`expr $x % 60`
	    x=`expr $x / 60`
	    m=`expr $x % 60`
	    printf "%02d:%02d\n" $m $s
	}

	POS=$(qdbus org.mpris.MediaPlayer2.$Player /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Position)
	TOTAL=$(qdbus org.mpris.MediaPlayer2.$Player /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Metadata | grep "^mpris:length" | awk '{print $2}')

		if [ -z $TOTAL ]
		then
            positionTime="00:00"
            lengthTime="00:00"
			length="stopped"	
			position=1		
		else
            positionTime=$(convertsec $POS)
            lengthTime=$(convertsec $TOTAL)
			length=$(($TOTAL/1000000))
			position=$(($POS/1000000))
		fi

	TEMP=$(qdbus org.mpris.MediaPlayer2.$Player /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Metadata | grep "artist:")
	artist=${TEMP##*:}
	TEMP=$(qdbus org.mpris.MediaPlayer2.$Player /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Metadata | grep "title:")
	title=${TEMP##*:}
	TEMP=$(qdbus org.mpris.MediaPlayer2.$Player /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Metadata | grep "album:")
	album=${TEMP##*:}
	COVER=$(qdbus org.mpris.MediaPlayer2.$Player /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Metadata | grep "artUrl:")
    str="'"

    
	if [ -n "$COVER" -a $position -ge 1 ]; then
        if [ "$Player" == "vlc" ]; then 
            uri=$(urlencode -d "$COVER")
            COVER=${uri#*//}
            convert "$COVER" '/tmp/tmp.png'
        else
            convert "${COVER#*//}" '/tmp/tmp.png'
        fi
	fi

	vol=$(qdbus org.mpris.MediaPlayer2.$Player /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Volume)	
    echo $length";"$position";"$artist";"$title";"$positionTime";"$lengthTime";"$vol";"$album

fi

exit 0
now.lua: replace all write_text calls with the new ones:

Code: Select all

                write_text(cr, 130,84,daten[3], {font="Dyuthi", size=22, align="l"}) --artist
                write_text(cr, 134,110,daten[8], {font="Dyuthi", size=16, align="l"}) --album
                write_text(cr, 134,126,daten[4], {font="Dyuthi", size=16, align="l"}) --titel	
                write_text(cr, 145,22,daten[5], {font="Dyuthi", size=12, align="l"})  --position
                write_text(cr, 410,22,daten[6], {font="Dyuthi", size=12, align="r"}) --length
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Now Playing Conky

Post by Logansfury »

Bleys wrote: Mon Feb 19, 2024 6:34 pm
Logansfury wrote: Mon Feb 19, 2024 4:21 pm Would this be difficult?
Not at all ;)

Screen Capture_select-area_20240219233006.png
mpris.sh:

Code: Select all

#!/bin/bash
#
# Bleys 2023
# dependencies: urlencode, qdbus
# sudo apt install gridsite-client qdbus
#
#
Player=$1

if [ $(ps -C $Player -o pid=) ]; then
convertsec() 
	{
	    x=`expr $1 / 1000000`
	    s=`expr $x % 60`
	    x=`expr $x / 60`
	    m=`expr $x % 60`
	    printf "%02d:%02d\n" $m $s
	}

	POS=$(qdbus org.mpris.MediaPlayer2.$Player /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Position)
	TOTAL=$(qdbus org.mpris.MediaPlayer2.$Player /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Metadata | grep "^mpris:length" | awk '{print $2}')

		if [ -z $TOTAL ]
		then
            positionTime="00:00"
            lengthTime="00:00"
			length="stopped"	
			position=1		
		else
            positionTime=$(convertsec $POS)
            lengthTime=$(convertsec $TOTAL)
			length=$(($TOTAL/1000000))
			position=$(($POS/1000000))
		fi

	TEMP=$(qdbus org.mpris.MediaPlayer2.$Player /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Metadata | grep "artist:")
	artist=${TEMP##*:}
	TEMP=$(qdbus org.mpris.MediaPlayer2.$Player /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Metadata | grep "title:")
	title=${TEMP##*:}
	TEMP=$(qdbus org.mpris.MediaPlayer2.$Player /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Metadata | grep "album:")
	album=${TEMP##*:}
	COVER=$(qdbus org.mpris.MediaPlayer2.$Player /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Metadata | grep "artUrl:")
    str="'"

    
	if [ -n "$COVER" -a $position -ge 1 ]; then
        if [ "$Player" == "vlc" ]; then 
            uri=$(urlencode -d "$COVER")
            COVER=${uri#*//}
            convert "$COVER" '/tmp/tmp.png'
        else
            convert "${COVER#*//}" '/tmp/tmp.png'
        fi
	fi

	vol=$(qdbus org.mpris.MediaPlayer2.$Player /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Volume)	
    echo $length";"$position";"$artist";"$title";"$positionTime";"$lengthTime";"$vol";"$album

fi

exit 0
now.lua: replace all write_text calls with the new ones:

Code: Select all

                write_text(cr, 130,84,daten[3], {font="Dyuthi", size=22, align="l"}) --artist
                write_text(cr, 134,110,daten[8], {font="Dyuthi", size=16, align="l"}) --album
                write_text(cr, 134,126,daten[4], {font="Dyuthi", size=16, align="l"}) --titel	
                write_text(cr, 145,22,daten[5], {font="Dyuthi", size=12, align="l"})  --position
                write_text(cr, 410,22,daten[6], {font="Dyuthi", size=12, align="r"}) --length
Far out!!

Bleys, yer a marvel :)
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Now Playing Conky

Post by Logansfury »

Your NowPlayingConky looks absolutely beautiful when paired with the cava-based equalizer you co-authored with Koentje :D

Image
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Now Playing Conky

Post by Logansfury »

WAZOO!!!!

I don't know what happened but on a whim I tried switching the player from audacious to vlc. It still didnt work, but then I switched to Qmmp which I prefer over audacious and IT WORKED :D
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Now Playing Conky

Post by Logansfury »

More fine touches. Changed the off-bars color from grey-green to white an set a partial transparency to compliment the white boarder and text of the NowPlayingConky.

Image

I thought it would be cool to make several conky.conf files for this widget, such as:

audacious.conf
qmmp.conf
celluloid.conf
vlc.conf

and also edited .lua versions

that last one is assuming I ever get VLC to work with this widget.
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Bleys
Level 4
Level 4
Posts: 431
Joined: Wed Apr 20, 2022 4:17 am
Location: Essen, Germany

Re: Now Playing Conky

Post by Bleys »

NowPlayingConky with the player starts and stops.

I use my own installation of NowPlayingConky for the procedure. All paths must be adapted to your own paths!

Create a new file in the NowPlaying directory and make the file executable: player.sh
Contents:

Code: Select all

#!/bin/bash
# replace clementine with your player
clementine &

sleep 1
cd $HOME/.conky/NowPlaying
conky -c conkyrc &
echo $! > /tmp/pid
exit 0
Create a new file in the NowPlaying directory and make the file executable: stop.sh
Contents:

Code: Select all

#!/bin/bash

f=$(</tmp/pid)
kill -15 $f
Install menulibre

Code: Select all

sudo apt install menulibre
open menulibre and search for your own player. Example Clementine:
Bildschirmfoto vom 2024-02-20 10-42-17.png
replace the command (clementine %u) with bash and the complete path to player.sh. Put single quotation marks around the path.
Depending on the launcher used (dock, bar, menu, etc.), it may be necessary to log out once.

Find in now.lua the if statement:

Code: Select all

        if result == player then
            .
            .
            .
        end

and extend the statement with a "else":

Code: Select all

        if result == player then
            .
            .
            .
        else
            stop=conky_parse('${exec bash stop.sh}')
        end

The complete if statement:

Code: Select all

        if result == player then
            daten = mysplit (conky_parse('${exec bash ./mpris.sh '..player..'}')) -- length pos artist titel postime lengthtime vol album
            if (daten[1]~="stopped") then
                color=0xffffff  alpha=0.1   typ=1
                draw_bg(cr,color,alpha,typ) -- Funktion Hintergrund Conky Bereich / Function Backgrounds Conky Area
                color=0xffffff  alpha=0.8   typ=2
                draw_bg(cr,color,alpha,typ) --zeichne Linie um den Bereich / Draw line around Conky Area
                if daten[4] == daten [8] then
                    daten[8]=" Single"
                end
                write_text(cr, 130,84,daten[3], {font="Dyuthi", size=22, align="l"}) --artist
                write_text(cr, 134,110,daten[8], {font="Dyuthi", size=16, align="l"}) --album
                write_text(cr, 134,126,daten[4], {font="Dyuthi", size=16, align="l"}) --titel	
                write_text(cr, 145,22,daten[5], {font="Dyuthi", size=12, align="l"})  --position
                write_text(cr, 410,22,daten[6], {font="Dyuthi", size=12, align="r"}) --length
                value=tonumber(daten[2])
                total=tonumber(daten[1])
                if (value == nil or total == nil) then
                    pct=1
                else
                    pct=value/total          
                    draw_bar(cr,pct,pt)
                    fDrawImage(cr,'/tmp/tmp.png',70,70,120,120)
                end
            end
        else
            stop=conky_parse('${exec bash stop.sh}') --Conky suicid
        end
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Now Playing Conky

Post by Logansfury »

I am trying to see which players I have that will work with this conky.

I have celluloid, and on it's info pages it says it has Mpris2, but the plugins section in preferences is blank.

Does anyone know how to enable the mpris on celluloid?
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Bleys
Level 4
Level 4
Posts: 431
Joined: Wed Apr 20, 2022 4:17 am
Location: Essen, Germany

Re: Now Playing Conky

Post by Bleys »

Logansfury wrote: Tue Feb 20, 2024 3:27 pm I am trying to see which players I have that will work with this conky.
https://vimeo.com/914939284?share=copy
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Now Playing Conky

Post by Logansfury »

Bleys wrote: Tue Feb 20, 2024 5:32 pm
Logansfury wrote: Tue Feb 20, 2024 3:27 pm I am trying to see which players I have that will work with this conky.
https://vimeo.com/914939284?share=copy
So Clementine, VLC, Audacious, and Qmmp are the only 4?
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Bleys
Level 4
Level 4
Posts: 431
Joined: Wed Apr 20, 2022 4:17 am
Location: Essen, Germany

Re: Now Playing Conky

Post by Bleys »

Logansfury wrote: Tue Feb 20, 2024 5:54 pm So Clementine, VLC, Audacious, and Qmmp are the only 4?
no... thats the 4 i've testet. Just tested celluloid. Has a "special" mpris feature. But it also works.

For reasons unknown to me, the Celluloid developers have made it difficult for others by choosing an almost impossible name under which the mpris metadata can be retrieved:

Code: Select all

io.github.celluloid_player.Celluloid.instance-1
For Celluloid to work, a line must be inserted in mpris.sh directly after the "Player active?" line:

Code: Select all

    if [ $Player == "celluloid" ]; then Player="io.github.celluloid_player.Celluloid.instance-1"; fi
view with the before and after line:

Code: Select all

if [ $(ps -C $Player -o pid=) ]; then
    if [ $Player == "celluloid" ]; then Player="io.github.celluloid_player.Celluloid.instance-1"; fi
convertsec() 
Screen Capture_select-area_20240220230130.jpg
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Now Playing Conky

Post by Logansfury »

Bleys wrote: Tue Feb 20, 2024 6:11 pm
Logansfury wrote: Tue Feb 20, 2024 5:54 pm So Clementine, VLC, Audacious, and Qmmp are the only 4?
no... thats the 4 i've testet. Just tested celluloid. Has a "special" mpris feature. But it also works.

For reasons unknown to me, the Celluloid developers have made it difficult for others by choosing an almost impossible name under which the mpris metadata can be retrieved:

Code: Select all

io.github.celluloid_player.Celluloid.instance-1
For Celluloid to work, a line must be inserted in mpris.sh directly after the "Player active?" line:

Code: Select all

    if [ $Player == "celluloid" ]; then Player="io.github.celluloid_player.Celluloid.instance-1"; fi
view with the before and after line:

Code: Select all

if [ $(ps -C $Player -o pid=) ]; then
    if [ $Player == "celluloid" ]; then Player="io.github.celluloid_player.Celluloid.instance-1"; fi
convertsec() 
Screen Capture_select-area_20240220230130.jpg
This got my Celluloid working, but like Qmmp, it doesnt correctly display the album art, being stuck on whatever art was last displayed. Only Audacious is working reliably. I am going to grab clementine from the software manager and see how that works for me. I would give real money to know what it is about my system that my players aren't working for me like they are for other users.
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Bleys
Level 4
Level 4
Posts: 431
Joined: Wed Apr 20, 2022 4:17 am
Location: Essen, Germany

Re: Now Playing Conky

Post by Bleys »

Test the mpris capabilities of a player:

Code: Select all

sudo apt install playerctl
Then:

Code: Select all

playerctl -l
this lists all active players that can be controlled via mpris with the actual names that must be used for the mpris queries.

Another player that only works if you know the correct name for mpris: QMPLay2
Start the Player: qmply2
Query mpris: QMPlay2
If you want to use QMPlay2, another IF query is required in mpris.sh.
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
Post Reply

Return to “Compiz, Conky, Docks & Widgets”