Xfce Forum

Sub domains
 

You are not logged in.

#1 2023-01-30 19:38:10

callmejoe
Member
Registered: 2019-11-19
Posts: 75

[solved] genmon tool tip

I've read the instructions here on how to add a tootip to the genmon plugin output. https://docs.xfce.org/panel-plugins/xfc … ugin/start

It works, but it also echos it to the panel output

what am i missing?  thanks

panel image
GImHeHC.png

script

#!/bin/bash

tooltip=$(playerctl metadata --format '{{artist}} - {{title}}')

if [[ $(playerctl -i firefox,chromium status) == "Playing" ]]
then
	playerctl metadata --format '{{ trunc(artist,22) }} - {{ trunc(title,26) }}';playerctl metadata --format '{{duration(position)}} | {{duration(mpris:length)}}'
else
if [[ $(playerctl -i firefox,chromium status) == "Paused" ]]
then
	playerctl metadata --format '{{ trunc(artist,22) }} - {{ trunc(title,26) }}';playerctl metadata --format '{{duration(position)}} | {{duration(mpris:length)}}  {{ uc(status) }}'
else
if [[ $(playerctl -i firefox,chromium status) == "Stopped" ]]
then
	playerctl metadata --format '{{ uc(status) }}'
else
	echo	
fi
fi
fi
echo "<tool>$tooltip</tool>"

Last edited by callmejoe (2023-01-31 02:52:17)

Offline

#2 2023-01-30 20:52:43

Skaperen
Member
From: right by Jesus, our Saviour
Registered: 2013-06-15
Posts: 819

Re: [solved] genmon tool tip

it's also echoing the tag.  my guess is that lone "echo" in the script (just before 3x"fi") is being run and the leading blank line messes up the XML parsing and it thinks the whole thing is pure text.   try changing that lone "echo" to "true" and see if that helps.

FYI, i've never done this part of Xfce before.  i'm just guessing.

Last edited by Skaperen (2023-01-30 20:53:36)

Offline

#3 2023-01-30 21:14:35

CwF
Member
Registered: 2018-01-28
Posts: 290

Re: [solved] genmon tool tip

Add quotes

tooltip="$....
as is
...
fi"

Offline

#4 2023-01-31 01:08:34

Skaperen
Member
From: right by Jesus, our Saviour
Registered: 2013-06-15
Posts: 819

Re: [solved] genmon tool tip

are you referring to the line with

tooltip=$(playerctl metadata --format '{{artist}} - {{title}}')

when you suggest using quotes?  coding '$(' and ')' produces a single uninterpreted result (unlike backtick quoting) and does not need quoting.

Offline

#5 2023-01-31 01:14:08

Skaperen
Member
From: right by Jesus, our Saviour
Registered: 2013-06-15
Posts: 819

Re: [solved] genmon tool tip

FYI: when posting code, it might be helpful to add line numbers.  "cat -n" can do that for you although it uses tabs after the number on each line.

     1	#!/bin/bash
     2	
     3	tooltip=$(playerctl metadata --format '{{artist}} - {{title}}')
     4	
     5	if [[ $(playerctl -i firefox,chromium status) == "Playing" ]]
     6	then
     7		playerctl metadata --format '{{ trunc(artist,22) }} - {{ trunc(title,26) }}';playerctl metadata --format '{{duration(position)}} | {{duration(mpris:length)}}'
     8	else
     9	if [[ $(playerctl -i firefox,chromium status) == "Paused" ]]
    10	then
    11		playerctl metadata --format '{{ trunc(artist,22) }} - {{ trunc(title,26) }}';playerctl metadata --format '{{duration(position)}} | {{duration(mpris:length)}}  {{ uc(status) }}'
    12	else
    13	if [[ $(playerctl -i firefox,chromium status) == "Stopped" ]]
    14	then
    15		playerctl metadata --format '{{ uc(status) }}'
    16	else
    17		echo	
    18	fi
    19	fi
    20	fi

it looks OK on my browser (Firefox 109).

Last edited by Skaperen (2023-01-31 01:18:38)

Offline

#6 2023-01-31 01:38:37

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,014

Re: [solved] genmon tool tip

@skaperen, the problem with this method is that it is not easy to copy and paste the code - you will always get the numbers added. We are better to just paste code without any line numbering prefix.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#7 2023-01-31 01:44:16

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,014

Re: [solved] genmon tool tip

@callmejoe, it is good practice for this plugin to use all of the tags. "<txt></txt>" for the text output and "<tool></tool>" for the tooltip. And as per @CwF, make sure you enclose output in quotes - especially of output may contain spaces.

I might recommend something like this:

#!/bin/bash

tooltip="$(playerctl metadata --format '{{artist}} - {{title}}')"

if [[ $(playerctl -i firefox,chromium status) == "Playing" ]]
then
	output="$(playerctl metadata --format '{{ trunc(artist,22) }} - {{ trunc(title,26) }}';playerctl metadata --format '{{duration(position)}} | {{duration(mpris:length)}}')"
else
if [[ $(playerctl -i firefox,chromium status) == "Paused" ]]
then
	output="$(playerctl metadata --format '{{ trunc(artist,22) }} - {{ trunc(title,26) }}';playerctl metadata --format '{{duration(position)}} | {{duration(mpris:length)}}  {{ uc(status) }}')
else
if [[ $(playerctl -i firefox,chromium status) == "Stopped" ]]
then
	output="$(playerctl metadata --format '{{ uc(status) }}')"
else
	output=""	
fi

echo "<txt>$output</txt>"
echo "<tool>$tooltip</tool>"

Note: I don't have playerctl installed to test.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#8 2023-01-31 02:52:01

callmejoe
Member
Registered: 2019-11-19
Posts: 75

Re: [solved] genmon tool tip

adding the output variable worked.  thanks!

echo "<txt>$output</txt>"
echo "<tool>"$tooltip"</tool>"

Offline

#9 2023-02-01 18:51:17

Skaperen
Member
From: right by Jesus, our Saviour
Registered: 2013-06-15
Posts: 819

Re: [solved] genmon tool tip

ToZ wrote:

@skaperen, the problem with this method is that it is not easy to copy and paste the code - you will always get the numbers added. We are better to just paste code without any line numbering prefix.

i use the "cut -c8-" command for cases like this.

Offline

#10 2023-02-01 22:32:13

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,014

Re: [solved] genmon tool tip

True, but direct copy/paste from the code block won't. Its an added step that some won't be able to or willing to perform. Best to keep it simple.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

Board footer

Powered by FluxBB