You are not logged in.
Pages: 1
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
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
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
Add quotes
tooltip="$....
as is
...
fi"
Offline
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
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
@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
@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
adding the output variable worked. thanks!
echo "<txt>$output</txt>"
echo "<tool>"$tooltip"</tool>"
Offline
@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
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
Pages: 1
[ Generated in 0.013 seconds, 7 queries executed - Memory usage: 559.19 KiB (Peak: 576.03 KiB) ]