You are not logged in.
Hiya, I have been trying to display colored output or an image in an executor's tooltip.
To sum up exactly what I'm trying to do, I'm using wttr.in to grab my local weather and using format=1
for a one liner on the status bar. This part of the bash script works exactly as intended.
Where I'm having an issue is with the tooltip. Currently I am executing the weather
function in my script a second time with the wttr.in options of 0pQ
and redirecting that to stderr
. This works however this has terminal escape codes for colors in it; I would like to have colors in the output.
This is currently my script.
#!/usr/bin/env bash
function weather() {
curl -s "https://wttr.in/$1$2" || exit
}
# Basic weather output.
# Example output:
# ? +12°C
printf "%s\n" "$(weather "$1" "?format=+%c+%t")"
# Slightly more weather information.
# Example output (should have color):
#
# \ / Partly cloudy
# _ /"".-. +13(12) °C
# \_( ). → 10 km/h
# /(___(__) 10 km
# 0.0 mm
# Redirecting to stderr will show up on the tooltip.
weather "$1" "?0pQ" 1>&2
And this is the relevant tint2rc executor for running the script:
execp = new
execp_command = weather Melbourne+Australia
execp_interval = 30
execp_continuous = 1
execp_has_icon = 0
execp_font = InconsolataGo Nerd Font Regular 11
execp_font_color = #cdd6f4 100
execp_background_id = 3
execp_centered = 1
execp_padding = 24 0
So far I have tried converting the ansi escape sequenced output into pango markup trying:
weather "$1" "?0pQ" | ansifilter -M | tail +n2 1>&2
with the relevant tint2rc option:
execp_markup = 1
however this prints out markup in the tooltip. Thought that this may work since rich text works on the executor stdout
. The output in the tooltip printed in plain text:
<span fgcolor="#ffff00"> \ /</span> Partly cloudy
<span fgcolor="#ffff00"> _ /""</span><span fgcolor="#bcbcbc">.-. </span> <span fgcolor="#87ff00">+13</span>(<span fgcolor="#5fff00">12</span>) °C
<span fgcolor="#ffff00"> \_</span><span fgcolor="#bcbcbc">( ). </span> <span font-weight="bold" fgcolor="#7f7f7f">→</span> <span fgcolor="#d7ff00">10</span> km/h
<span fgcolor="#ffff00"> /</span><span fgcolor="#bcbcbc">(___(__) </span> 10 km
0.0 mm
.
I have also tried to use a png (which wttr.in offers as an output) since tooltips can display a window image as a tooltip. Sadly this also outputs the contents of the png in plaintext.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=fvpF*'uuuXV9w\pE֮Kn+Wtvp5#dԉ
!6Vu5ΣsfKyOvpV@ѧZZZ8x -ߟ'|pڏhL͛۾/))'5kͥ{ĝnLN>K*ɵB($B($B!
.ѣƏavYvУ[uC]ùjm}@Wh=uC8sŢfeRR >^h^@0b^t;|]n/W,i(ؾ]mi)))˖-[vpL!l(+sp~~pvS!B{>f3h++UWIKnxJD_(J;
IPH(B@!
$B($B!
I0Hw @!kAP?^JcIENDB`
Thought that this would be the best place to ask if anybody has any experience with this and anyway to potentially get colored output in an executor tooltip (or image)? Any help will be greatly appreciated
Last edited by brushy (2023-09-09 06:23:08)
Offline
Unfortunately I can't find anything quickly now...
If I'm not mistaken, for the display of these small graphics, the font used was crucial.
Offline
You mean like using something like font awesome or a nerd font?
Offline
I meant mono fonts.
Or, you can look here:
Supported output formats and views
or
https://wttr.in/:help
Offline
Ahh okay, I get you. InconsolataGo is a monospace font and I use it across all of my tint2conf. Here's a screenshot of where I'm using the wttr.in options of ?0pQT
For the most part, the font itself isn't the issue as for when I turn off terminal sequences, it displays correctly.
Thanks for trying to help though. I'll likely need to look through the tint2 code base and write myself a patch. Since outputting an image is possible for task tooltips, I should theoretically be able duplicate that into the executor side of things. From memory, it's creating a screenshot using cairo but I might be wrong since I haven't looked at the codebase in a few years.
I was hoping that somebody knew how to hack something together on the script side of things before needing to deepdive more into the code.
Last edited by brushy (2023-09-10 23:04:10)
Offline
Sorry I'm not much help.
Looking at your screenshot, at least 2 users here have done this before.
You should still have patience...
and ?0pQT means 'no colors'.
Last edited by unklar (2023-09-11 08:41:54)
Offline
Indeed, with colors I get this:
I don't think it's a font issue and more that the output is snprintf
'd instead of being aware of what the terminal escape sequences mean
Also, I honestly do appreciate the time you've given me the past couple of days in answering my somewhat not-strictly-nessecary feature question. I've realised that I'm asking about something that seems to be a limitation in tint2's capability and requires more than just a bash based hack.
Last edited by brushy (2023-09-12 02:36:49)
Offline