You are not logged in.

#1 2016-08-31 05:59:53

Waxolunist
Member
Registered: 2016-05-15
Posts: 7

Non-conky weather script

All I've found about weather scripts here are conkyrelated. The bunsenlabsweather.sh script needs configuration.

Here is my suggestion for a small weather app using wttr.in:

$ cat bin/weather 
#!/bin/sh

CMD="curl -s -4 --connect-timeout 1 http://wttr.in"
CACHEDIR="$HOME/.cache/weather"
CACHEFILE="$CACHEDIR/weather"

mkdir -p "$CACHEDIR"
touch "$CACHEFILE"

WEATHER=$($CMD)

if [ $? -eq 0 ]; then
	echo "$WEATHER" > "$CACHEFILE"	
fi

less -r -S "$CACHEFILE"

If no internet connection is available use that from the cache.
The script always shows the weather of your current location (see wttr.in rest api).

I call it from openbox with the shortcut Win+F5, because on my thinkpad the key F5 has a sun printed on it:

    <keybind key="W-F5">
      <action name="Execute">
        <startupnotify>
          <enabled>false</enabled>
          <name>weather</name>
        </startupnotify>
        <command>x-terminal-emulator -m -T 'Wttr.in' -e ~/bin/weather</command>
      </action>
    </keybind>

Offline

#2 2016-09-01 13:52:17

qcgxr
Member
Registered: 2016-08-31
Posts: 29

Re: Non-conky weather script

Isn't wttr.in just a web gui for wego? Why not use wego directly?

Offline

#3 2016-09-01 15:06:34

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: Non-conky weather script

Here is a script snippet I use. It displays in a terminal, and you can pass a location to the script as well

terminal="urxvt"

if [[ $1 ]];then
    $terminal -g 130x40 -T "Weather in $1" -hold -e sh -c "curl -4 http://wttr.in/$1"
else
    $terminal -g 130x40 -T "Local Weather" -hold -e sh -c "curl -4 http://wttr.in/"
fi

exit

I like your method of caching the data offline.


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#4 2016-09-02 06:44:31

ohnonot
...again
Registered: 2015-09-29
Posts: 5,592

Re: Non-conky weather script

it doesn't format properly in a standard 80x24 terminal (urxvt user here).

also, i'd suggest changing the word "weather", which is very generic, to something more specific, because other apps might be using a cache dir of the same name...

Waxolunist wrote:
CACHEDIR="$HOME/.cache/weather"
CACHEFILE="$CACHEDIR/weather"

=================


qcgxr wrote:

Isn't wttr.in just a web gui for wego? Why not use wego directly?

indeed it seems to be.
but who wants to install/use go...

Last edited by ohnonot (2016-09-02 06:44:42)

Offline

Board footer

Powered by FluxBB