Ansi Weather


Getting weather information is really useful. What happens if you're at the command line in Linux? I found a really little application that can help
ansiweather
apt install ansiweather
ansiweather -l Plymouth, UK

So what else can we do with this
- Send the output to Mastodon with toot post
This is a two step process
- ansiweather -l Plymouth, UK > weather.txt
- toot post < weather.txt
Will send the weather info to Mastodon.
However this does not include any date info
We can fix this with
- date > weatherinfo.txt
- ansiweather -l Plymouth, UK >> weatherinfo.txt
then send the whole lot to Mastodon with
- toot post < weatherinfo.txt
So, if we put this in to a final shell script we need:-
#send weather info to Mastodon
# current date
date > weatherinfo.txt
# current weather
ansiweather -l Plymouth, UK >> weatherinfo.txt
#send to Mastodon
toot post < weatherinfo.txt
# done
echo done
Again released under GPLv3
I tried to get festival to speak the weather, it is not perfect but this sort of works, you will need to direct to weather.txt first.
festival —tts < weather.txt
Looking in to this further, the issue is the brackets etc, so this stackoverflow post
strips out the colour formatting
sed 's/\x1b[[^\x1b]*m//g' weatherinfo.txt
Therefore
sed 's/\x1b[[^\x1b]*m//g' weatherinfo.txt > weatherinfo2.txt
Sends the newly formatted text to weatherinfo2.txt
So running back through festival
festival —tts < weather.txt
Is perhaps a little better, but not perfect
So going back to what we wrote earlier to send to Mastodon, the new script
1 #send weather info to Mastodon
2 # current date
3 date > weatherinfo.txt
4 # current weather
5 ansiweather -l Plymouth, UK >> weatherinfo.txt
6 # clean up output with sed
7 sed 's/\x1b\[[^\x1b]*m//g' weatherinfo.txt > weatherinfo2.txt
8 #send to Mastodon
9 toot post < weatherinfo2.txt
10 # done
11 echo done
Produces much nicer output. The top bottom part of this illustrates what was sent before we stripped out the colour formatting
However it still isn't perfect, as it removes part some of the wording, but it is hopefully getting there.

REFERENCES
TAGS
#YearOfTheFediverse,#Weather,#Scripting,#Bash,#Linux,
#Mastodon,#ProblemSolving,#AnsiWeather,#programming,
#Stackoverflow,#sed,#cat,#grep,GPL3,#FSF

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License
AI statement : Consent is NOT granted to use the content of this blog for the purposes of AI training or similar activity. Consent CANNOT be assumed, it has to be granted.
