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
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 »

Hey Bleys,

As far as assigning Album Art to the mp3 Tag info, Is the Ruby-mp3tag that I see in Software Manager the same thing as mp3tag for windows? I'm curious to see if I can add album art to files without having to swap my KVM switch to the windows machine?
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 »

I get a blank widget when I play a song on clementine. No album art, no song info.

Does mpris need to be enabled in some way?
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 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
Have you uploaded these files Bleys? I would love to try this on my system :)
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 7:33 pm
Does mpris need to be enabled in some way?
no

output (Clementinie running):

Code: Select all

qdbus org.mpris.MediaPlayer2.clementine /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Metadata
Example with me:
Screen Capture_select-area_20240221124823.jpg
Logansfury wrote: Have you uploaded these files Bleys?
not yet
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 »

Hello Bleys!

I hope you have been well.

I have NowPlaying working with audacious, rhythmbox, clementine, and the non-flatpak of VLC which I now have installed alongside the flatpak.

I took a look at your mpris.sh and tried to deduce how you added the album info display that I had asked for. As an experiment to get more familiar with the code, I did an edit attempt to add album year to the display. I didnt break anything, but I failed to get the display. I think maybe the term "year" isnt completely what mpris uses to store album year data? Here are my edits:

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
        if [ $Player == "celluloid" ]; then Player="io.github.celluloid_player.Celluloid.instance-1"; fi
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##*:}
	TEMP=$(qdbus org.mpris.MediaPlayer2.$Player /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Metadata | grep "year:")
	year=${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";"$year

fi

exit 0[/code

As you can see, I added [code]TEMP=$(qdbus org.mpris.MediaPlayer2.$Player /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Metadata | grep "year:")
	year=${TEMP##*:}

and

echo $length";"$position";"$artist";"$title";"$positionTime";"$lengthTime";"$vol";"$album";"$year

Was this the correct syntax, but year is the wrong variable, or am I way way off?
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 »

I just found a page online that looks like it contains the mpris variables and I searched the entire document, there is no instance of year!

I did find genre, and changed the relevant parts of the code:

Code: Select all

	TEMP=$(qdbus org.mpris.MediaPlayer2.$Player /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Metadata | grep "genre:")
	genre=${TEMP##*:}
echo $length";"$position";"$artist";"$title";"$positionTime";"$lengthTime";"$vol";"$album";"$genre

This did not display any genre data so I guess I did not edit the document correctly.
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 Apr 16, 2024 8:43 pm echo $length";"$position";"$artist";"$title";"$positionTime";"$lengthTime";"$vol";"$album";"$genre

This did not display any genre data so I guess I did not edit the document correctly.
Of course it is not enough to just add a new variable to the return of mpris.sh!
If a new variable is added to the output of mpris.sh, this also expands the "data" array within now.lua
in your case the genre would be in daten[9] and you would have to add another line "write_text" within the now.lua with x,y where you want it:

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
                write_text(cr, xxx,xxx,daten[9], {font="Dyuthi", size=12, align="r"}) --genre
                
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 Apr 21, 2024 1:39 pm
Logansfury wrote: Tue Apr 16, 2024 8:43 pm echo $length";"$position";"$artist";"$title";"$positionTime";"$lengthTime";"$vol";"$album";"$genre

This did not display any genre data so I guess I did not edit the document correctly.
Of course it is not enough to just add a new variable to the return of mpris.sh!
If a new variable is added to the output of mpris.sh, this also expands the "data" array within now.lua
in your case the genre would be in daten[9] and you would have to add another line "write_text" within the now.lua with x,y where you want it:

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
                write_text(cr, xxx,xxx,daten[9], {font="Dyuthi", size=12, align="r"}) --genre
                
Hello Bleyz,

It's great to hear from you!

Wow, I was close, I only missed one step!

May I ask where you found the list to know which number of daten is which?
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: Sun Apr 21, 2024 1:57 pm
May I ask where you found the list to know which number of daten is which?
[/quote]
Screen Capture_select-area_20240421202027.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: Sun Apr 21, 2024 2:21 pm
Logansfury wrote: Sun Apr 21, 2024 1:57 pm
May I ask where you found the list to know which number of daten is which?
Screen Capture_select-area_20240421202027.jpg
[/quote]

Got it! going to do an experiment edit :)
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 »

This is strange.

I set the genre tag for an entire directory of songs with MusicBrainz Picard and then edited the mpris and lua files:

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
        if [ $Player == "celluloid" ]; then Player="io.github.celluloid_player.Celluloid.instance-1"; fi
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##*:}
    	TEMP=$(qdbus org.mpris.MediaPlayer2.$Player /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Metadata | grep "genre:")
    	genre=${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";"$genre

fi

exit 0
and the now.lua:

Code: Select all

require 'cairo'
require "imlib2"
home_path = os.getenv ('HOME')
-- Hier den genutzen Pfad zum Conky Verzeichnis eintragen / Enter the used path to the Conky directory here 
conky_path = home_path..'/.conky/NowPlayingConky/'
-- Ende Pfad zum Conky Verzeichnis / End Path
image_path = '/tmp/'
pt={}
pt['bg_color']=0xffffff
pt['bg_alpha']=0.3
pt['fg_color']=0xffffff
pt['fg_alpha']=1.0
pt['width']=194
pt['height']=6
pt['x']=180
pt['y']=15
vl={}
vl['bg_color']=0xffffff
vl['bg_alpha']=0.3
vl['fg_color']=0xffffff
vl['fg_alpha']=1.0
vl['width']=210
vl['height']=6
vl['x']=158
vl['y']=17
function rgb_to_rgba(color,alpha)
	return ((color / 0x10000) % 0x100) / 255., ((color / 0x100) % 0x100) / 255., (color % 0x100) / 255., alpha
end
function mysplit (inputstr, sep)
        if sep == nil then
                sep = ";"
        end
        local t={}
        for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
                table.insert(t, str)
        end
        return t
end
function draw_bg(cr,color,alpha,typ) -- zeichne Hintergrund Conky Fenster / draw Conky Area Background
    local corner_r=20
    local bg_color=color 

    local bg_alpha=alpha
	local w=conky_window.width
	local h=conky_window.height
	cairo_set_source_rgba(cr,rgb_to_rgba(bg_color,bg_alpha))
	cairo_move_to(cr,corner_r,0)
	cairo_line_to(cr,w-corner_r,0)
	cairo_curve_to(cr,w,0,w,0,w,corner_r)
	cairo_line_to(cr,w,h-corner_r)
	cairo_curve_to(cr,w,h,w,h,w-corner_r,h)
	cairo_line_to(cr,corner_r,h)
	cairo_curve_to(cr,0,h,0,h,0,h-corner_r)
	cairo_line_to(cr,0,corner_r)
	cairo_curve_to(cr,0,0,0,0,corner_r,0)
	cairo_close_path(cr)
	
    if typ==1 then
	    cairo_fill(cr)
    else
        cairo_stroke(cr)
    end
end 
function fDrawImage(cr,path,x,y,w,h)
    cairo_save (cr)
    local img =  cairo_image_surface_create_from_png(path)
    local w_img, h_img = cairo_image_surface_get_width(img), cairo_image_surface_get_height(img)
    cairo_translate (cr, x, y)
    cairo_scale (cr, w/w_img, h/h_img)
    cairo_set_source_surface (cr, img, -w_img/2, -h_img/2)
    cairo_paint (cr)
    cairo_surface_destroy (img)
    collectgarbage ()
    cairo_restore (cr)
end
function draw_bar(cr,pct,pt)
    local bgc, bga, fgc, fga=pt['bg_color'], pt['bg_alpha'], pt['fg_color'], pt['fg_alpha']
    local w=pct*pt['width']
    local x=pt['x']
    local y=pt['y']
--  Background
    cairo_rectangle(cr, x, y, pt['width'], pt['height'])
    cairo_set_source_rgba(cr,rgb_to_rgba(bgc,bga))
    cairo_fill(cr)
--  Indicator
    cairo_rectangle(cr, x, y, w, pt['height'])
    cairo_set_source_rgba(cr,rgb_to_rgba(fgc,fga))
    cairo_fill(cr)
    cairo_stroke (cr)
end
function write_text(cr, x, y, text, f)
--write_text(cr, x, y, text, {})
--font attributes (Schriftattribute zuweisen oder default Werte annehmen)
      local font=f.font or "Neon 80s"
      local size=f.size or 10
      local align=f.align or 'l'
      local bold=f.bold or false
      local ital=f.italic or false
      local color=f.color or "0xffffff"
      local slant=CAIRO_FONT_SLANT_NORMAL
      if ital then slant=CAIRO_FONT_SLANT_ITALIC end
      local weight=CAIRO_FONT_WEIGHT_NORMAL
      if bold then weight=CAIRO_FONT_WEIGHT_BOLD end

--Text Size (Textgröße für die Plazierung bestimmen.)
      local x_a=0
      local y_a=0
      local te = cairo_text_extents_t:create()
      tolua.takeownership(te)
      cairo_select_font_face (cr, font, slant, weight)
      cairo_set_font_size (cr, size)
      cairo_text_extents (cr, text, te)

--Text Position
      if align=='c' then
        x_a = -(te.width/2+te.x_bearing)
        y_a = -(te.height/2+te.y_bearing)
      end
      if align=='r' then
        x_a = -(te.width+te.x_bearing)
        --y_a = -(te.height+te.y_bearing)
      end

--Schadow 1 Pixel (Schatten für den Text um 1 Pixel versetzt)
      cairo_set_source_rgba(cr, rgb_to_rgba(0x000000,1))

      cairo_move_to (cr, x+1+x_a, y+1+y_a)
      cairo_show_text (cr, text)
      cairo_stroke(cr)

-- Now Text on Top (nun den Text oben drauf)
      cairo_set_source_rgba(cr, rgb_to_rgba(color,1))
      cairo_move_to (cr, x+x_a, y+y_a)
      cairo_show_text (cr, text)
      cairo_stroke(cr)
end
function conky_main()
    function running(cr,player) -- is Player running? / läuft der Player?
        local handle = io.popen("ps -U root -u root -N | awk '/"..player.."/{print $4}'")
        local result = handle:read()
        handle:close()
        if result == player then
            daten = mysplit (conky_parse('${exec bash '..conky_path..'mpris.sh '..player..'}')) -- $laenge";"$position";"$artist";"$titel";"$positionZeit";"$laengeZeit";"$volume
--print(daten[1])
            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
                write_text(cr, 130,64,daten[3], {font="Neon 80s", size=22, align="l"}) -- artist
                write_text(cr, 134,84,daten[8], {font="Neon 80s", size=16, align="l"}) --album
                write_text(cr, 134,106,daten[4], {font="Neon 80s", size=16, align="l"}) -- title	
                write_text(cr, 134,126,daten[9], {font="Neon 80s", size=16, align="l"}) -- genre
                write_text(cr, 145,22,daten[5], {font="Neon 80s", size=12, align="l"})  -- position
                write_text(cr, 410,22,daten[6], {font="Neon 80s", 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)
--                    volume=tonumber(daten[7])
--                    draw_bar(cr,volume,vl)
	                fDrawImage(cr,'/tmp/tmp.png',70,70,120,120)
                end
            end
        end
    end
	if conky_window==nil then return end
	local cs=cairo_xlib_surface_create(conky_window.display,conky_window.drawable,conky_window.visual, conky_window.width,conky_window.height)	
	local cr=cairo_create(cs)		
	local updates=conky_parse('${updates}')
	update_num=tonumber(updates)
	if update_num>5 then
-- Player Auswahl. Jeder mpris unterstützende Player ist möglich. / Player selection. Any mpris supporting player is possible.
        player="audacious"

        running(cr,player)
	end

   cairo_surface_destroy(cs)
   cairo_destroy(cr)
end
I moved the 3 existing lines of text up 20 pixels to make room for an additional line of text, but there is no display of genre, even though hovering over the mp3 in audacious shows the genre category in the tag popup.

Where did I go wrong please?
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 »

You can also call up mpris.sh directly in the terminal with the player used as a parameter.
There you can see whether the genre is supplied.
Screen Capture_select-area_20240423160048.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 »

For some reason I am getting different results than you are following the same instructions.

Ghosts in the machine are driving me crazy.

My now.lua is properly edited:

Code: Select all

                write_text(cr, 130,64,daten[3], {font="Neon 80s", size=22, align="l"}) -- artist
                write_text(cr, 134,84,daten[8], {font="Neon 80s", size=16, align="l"}) --album
                write_text(cr, 134,106,daten[4], {font="Neon 80s", size=16, align="l"}) -- title	
                write_text(cr, 134,126,daten[9], {font="Neon 80s", size=16, align="l"}) -- genre
                write_text(cr, 145,22,daten[5], {font="Neon 80s", size=12, align="l"})  -- position
                write_text(cr, 410,22,daten[6], {font="Neon 80s", size=12, align="r"}) -- length
The proper data is added to the mpris.sh:

Code: Select all

	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##*:}
    	TEMP=$(qdbus org.mpris.MediaPlayer2.$Player /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Metadata | grep "genre:")
   	 genre=${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";"$genre
When I check my tags in an editor, or hover my mouse over the playing title, it shows the genre field displayed and populated with a value.

Despite all this, I am not getting the same terminal return when playing a song with genre info loaded:

Code: Select all

logansfury@OptiPlex-5040:~$ cd .conky/NowPlayingConky
logansfury@OptiPlex-5040:~/.conky/NowPlayingConky$ ./mpris.sh audacious
338;81; Whitesnake; Crying in the Rain;01:21;05:38;1; Whitesnake;;
logansfury@OptiPlex-5040:~/.conky/NowPlayingConky$
This just makes no sense :(
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 Apr 23, 2024 12:21 pm
logansfury@OptiPlex-5040:~/.conky/NowPlayingConky$ ./mpris.sh audacious
338;81; Whitesnake; Crying in the Rain;01:21;05:38;1; Whitesnake;;
logansfury@OptiPlex-5040:~/.conky/NowPlayingConky$

This just makes no sense :(
Simple answer: audacious simple does not output a genre via mpris...

Code: Select all

ralf@Nexus:~$ qdbus org.mpris.MediaPlayer2.clementine /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Metadata
bitrate: 192
mpris:artUrl: file:///tmp/clementine-art-lnxnjy.jpg
mpris:length: 174000000
mpris:trackid: /org/clementineplayer/Clementine/Track/184
xesam:album: Fetenhits Oldies CD 2
xesam:artist: Scott McKenzie
xesam:contentCreated: 2023-08-09T22:23:35
xesam:genre: Oldies
xesam:title: San Francisco
xesam:trackNumber: 20
xesam:url: file:///home/ralf/Musik/Favoriten/Scott McKenzie - San Francisco.mp3
ralf@Nexus:~$ qdbus org.mpris.MediaPlayer2.audacious /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Metadata
mpris:artUrl: file:///tmp/audacious-temp-VD2XM2
mpris:length: 175099000
mpris:trackid: 
xesam:album: Fetenhits Oldies CD 2
xesam:artist: Scott McKenzie
xesam:title: San Francisco
xesam:url: file:///home/ralf/Musik/Favoriten/Scott%20McKenzie%20-%20San%20Francisco.mp3
ralf@Nexus:~$ 

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 »

Simple answer: audacious simple does not output a genre via mpris...
Well that's depressing. It's an otherwise awesome player with a great mouse hover feature that pops up a tag info and album art window.

I have NowPlaying working with clementine, non-flatpak vlc, and rhythmbox. I will test the mpris terminal code on those, and edit the player specific .lua's I have to display more info where available.
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 »

Success!

I have genre displaying on non-flatpak VLC display. Moving on to the other players to see which will also display genre.
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 »

I got track number displaying on vlc and I think contentCreated is my year value :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 »

WAZOO!!!!

Look at all the output I am getting from VLC:
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 »

Wow, look at the difference in display data available between audacious and VLC:

Code: Select all

logansfury@OptiPlex-5040:~$ qdbus org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Metadata
mpris:artUrl: file:///home/logansfury/.cache/vlc/art/artistalbum/Kiss/Love%20Gun/art.jpg
mpris:length: 208147500
mpris:trackid: 
vlc:length: 208147
vlc:publisher: 3
vlc:time: 208
xesam:album: Love Gun
xesam:artist: Kiss
xesam:contentCreated: 1977
xesam:genre: Glam Rock
xesam:title: Plaster Caster
xesam:tracknumber: 9
xesam:url: file:///home/logansfury/Music/KISS%2009.%20Plaster%20Caster.mp3
logansfury@OptiPlex-5040:~$ qdbus org.mpris.MediaPlayer2.audacious /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Metadata
mpris:artUrl: file:///tmp/audacious-temp-LEAJM2
mpris:length: 198693000
mpris:trackid: 
xesam:album: Love Gun
xesam:artist: Kiss
xesam:title: Love Gun
xesam:url: file:///home/logansfury/Music/KISS%2006.%20Love%20Gun.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 »

I am having a difficulty with the display.

I can make a space fine: write_text(cr, 134,84,daten[11] .. " ", {font="Neon 80s", size=16, align="l"}) -- contentCreated

but I cannot make a space, dash and space. This only shows the first space, the dash, then the next value is right against the dash with no separating space: write_text(cr, 134,126,daten[10] .." - ", {font="Neon 80s", size=16, align="l"}) -- tracknumber

How on earth do I get a space, dash, and space displayed in .lua? I have been asking online coding resources but they are worthless here.
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
Post Reply

Return to “Compiz, Conky, Docks & Widgets”