chubin / wttr.in

:partly_sunny: The right way to check the weather
https://wttr.in
Apache License 2.0
24.42k stars 1.1k forks source link

Option for title / status line #539

Open nick87720z opened 3 years ago

nick87720z commented 3 years ago

TODO

Details

For now page name looks like "Weather report for Cityname". Would be way more useful if it allowed to be set from one of 4 one-line formats, 1..4. With browser/viewer own auto-update this would allow to monitor weather right in taskbar.

Btw, tittle could be set in X terminals with termcap sequences (just like text style), but that will require URL option to pass TERM, as well as move to non-hardcoded termcap codes. Here is my bash test for such feature (w3m would be great viewer if not problems with colors and png at least at wttr):

#!/bin/sh

pid=0
if tput hs; then
  { while true; do
    echo "$(tput tsl)$(curl --silent 'https://wttr.in/?format=2)$(tput fsl)"
    sleep 1800
  done; } &
  pid=$!
fi

while true; do
  curl --silent 'https://wttr.in/?format=v2
  sleep 1800
done

kill $pid

Edit: My example screenshot with xterm variant. taskbar-weather-applet-london

chubin commented 3 years ago

Wow! That's a nice idea! What do you think about this option:

For HTML pages , it configures the window title (<head><title>{{ title }}</title></head>), and for the ANSI output, configures the terminal output.

If it is not specified, the standard title format is used for HTML, and no title for the ANSI output.

Agreed?

nick87720z commented 3 years ago

Ok

I have to note yet - these features (tsl/fsl) are not included in most TERM types, suitable to be set in terminals (like xterm, xterm-256color, mlterm, vte). Instead there are few separate files, ending with "+sl" (I have only {xterm,dec,sun}+sl). I'm not sure, how best match is determined automatically. At least MC has no problem setting title in any gui term, without even providing extra option for what specific term type to use.

xterm+sl works in all gui terminals I have installed (xterm, mlterm, alacritty, all vte-based), though at least one (rxvt-unicode) has it in core term defs (though also ok with xterm+sl).

These terms seem to have no features but statusline support - at least no colors, font styles, and mc showes mess instead of ui (as if piped through cat).

There is what I first found, how to do it with tput: https://serverfault.com/questions/23978/how-can-one-set-a-terminals-title-with-the-tput-command

This oneliner lists terminals with sl support (there are many of them): find /usr/share/terminfo -type f -printf '%f\n' | sort | { while read t; do TERM=$t tput hs && echo $t; done; }