You are not logged in.


Given the device's hardware and space limitations, I'm having to use a network-installed Xubuntu 14.04 on a UMID MBook M1. ToZ's weather script (ver. 4.11 xfce panel weather app is defunct), for some reason, isn't caching though I have both wxcache and wxdata-cached files in /tmp.
So without active wifi, the genmon disables itself upon trying to update. (I've commented-out the original curl to shorten the output.)
/tmp/wxdata-cached reads "The page you requested was removed." which may be from an older attempt. I deleted that and upon updating, the file remains blank.
Any handle to jiggle here?
#!/bin/bash
wxcache=${HOME}/tmp/wxdata-cached
SITE="Wheaton"
LATITUDE="39.0398"
LONGITUDE="-77.0553"
CLICK_COMMAND="xfce4-terminal -H --geometry=126x41 -T "Weather" -x curl -s wttr.in/$LATITUDE,$LONGITUDE"
##CLICK_COMMAND="xfce4-terminal -H -- font "BoldSystem.ttf 16" --geometry=126x41 -T "Weather" -x curl -s wttr.in/$LATITUDE,$LONGITUDE"
function toDate
{
HOUR=$(echo $1 | awk -F':' '{print $1}')
MINUTE=$(echo $1 | awk -F':' '{print $2}')
case $HOUR in
"00") HOUR="12" AMPM="am" ;;
"01") HOUR="1" AMPM="am" ;;
"02") HOUR="2" AMPM="am" ;;
"03") HOUR="3" AMPM="am" ;;
"04") HOUR="4" AMPM="am" ;;
"05") HOUR="5" AMPM="am" ;;
"06") HOUR="6" AMPM="am" ;;
"07") HOUR="7" AMPM="am" ;;
"08") HOUR="8" AMPM="am" ;;
"09") HOUR="9" AMPM="am" ;;
"10") HOUR="10" AMPM="am" ;;
"11") HOUR="11" AMPM="am" ;;
"12") HOUR="12" AMPM="am" ;;
"13") HOUR="1" AMPM="pm" ;;
"14") HOUR="2" AMPM="pm" ;;
"15") HOUR="3" AMPM="pm" ;;
"16") HOUR="4" AMPM="pm" ;;
"17") HOUR="5" AMPM="pm" ;;
"18") HOUR="6" AMPM="pm" ;;
"19") HOUR="7" AMPM="pm" ;;
"20") HOUR="8" AMPM="pm" ;;
"21") HOUR="9" AMPM="pm" ;;
"22") HOUR="10" AMPM="pm" ;;
"23") HOUR="11" AMPM="pm" ;;
esac
echo "$HOUR:$MINUTE $AMPM"
}
#OUT=$(curl ${wxcache} -s wttr.in/$LATITUDE,$LONGITUDE?format="%C\n%h\n%t\n%f\n%w\n%l\n%m\n%M\n%p\n%P\n%D\n%S\n%z\n%s\n%d\n%C\n&?u")
OUT=$(curl ${wxcache} -s wttr.in/$LATITUDE,$LONGITUDE?format=%t | sed 's/+//g')
WEATHERICON=$(echo $OUT | awk '{print $1}')
HUMIDITY=$(echo $OUT | awk '{print $2}')
TEMPERATURE=$(echo $OUT | awk '{print $3}' | sed -e 's/+//g' | sed -e 's/^-0/0/g' )
FEELSLIKE=$(echo $OUT | awk '{print $4}' | sed -e 's/+//g' | sed -e 's/^-0/0/g' )
WIND=$(echo $OUT | awk '{print $5}')
LOCATION=$(echo $OUT | awk '{print $6}')
MOONPHASE=$(echo $OUT | awk '{print $7}')
MOONDAY=$(echo $OUT | awk '{print $8}')
PRECIPITATION=$(echo $OUT | awk '{print $9}')
PRESSURE=$(echo $OUT | awk '{print $10}')
DAWN=$(toDate "$(echo $OUT | awk '{print $11}')")
SUNRISE=$(toDate "$(echo $OUT | awk '{print $12}')")
ZENITH=$(toDate "$(echo $OUT | awk '{print $13}')")
SUNSET=$(toDate "$(echo $OUT | awk '{print $14}')")
DUSK=$(toDate "$(echo $OUT | awk '{print $15}')")
WEATHERCONDITION=$(echo $OUT | awk '{print $16" "$17" "$18}')
if [ "$1" == "debug" ]; then
echo "OUT=$OUT"
echo "WEATHERICON=$WEATHERICON"
echo "HUMIDITY=$HUMIDITY"
echo "TEMPERATURE=$TEMPERATURE"
echo "FEELSLIKE=$FEELSLIKE"
echo "WIND=$WIND"
echo "LOCATION=$LOCATION"
echo "MOONPHASE=$MOONPHASE"
echo "MOONDAY=$MOONDAY"
echo "PRECIPITATION=$PRECIPITATION"
echo "PRESSURE=$PRESSURE"
echo "DAWN=$DAWN"
echo "SUNRISE=$SUNRISE"
echo "ZENITH=$ZENITH"
echo "SUNSET=$SUNSET"
echo "DUSK=$DUSK"
echo "WEATHERCONDITION=$WEATHERCONDITION"
fi
#do the genmon
echo -e "<txt><span size='x-large'>$WEATHERICON</span><span rise='3000'> $TEMPERATURE</span></txt>"
echo -e "<txtclick>$CLICK_COMMAND</txtclick>"
echo -e "<tool><span font_desc='Bold 16'>$WEATHERICON</span> <b><big>$SITE</big></b>
$TEMPERATURE <small>and</small> $WEATHERCONDITION
<small>
Feels like:\t$FEELSLIKE
Humidity:\t$HUMIDITY
Wind:\t\t$WIND
Precipitation:\t$PRECIPITATION
Pressure:\t$PRESSURE
Rise/Set:\t$SUNRISE / $SUNSET
Moon:\t\t$MOONPHASE
</small>
<span size='x-small'>$(date)</span></tool>"
exit 0Last edited by jakfish (2026-08-16 18:19:06)
Offline


The site (wttr.in) appears to be down right now.
Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline


I believe it's back up. Went to wttr.in and it brought up the weather of my location w/o having to add the city, etc.
Added later 6 h 11 min 42 s:
I cheated with AI and it generated this script that seems to cache the temperature. But it's not clear to me how the script knows my location (Wheaton, MD) unless it's finding it through my IP or something even more nefarious. AI is probably emptying my bank account right now.
#!/bin/bash
CACHE_FILE="/tmp/wttr_temp.txt"
MAX_AGE=300 # Cache time in seconds (5 minutes)
# Check if cache file exists and is newer than MAX_AGE
if [ ! -f "$CACHE_FILE" ] || [ $(($(date +%s) - $(stat -c %Y "$CACHE_FILE" 2>/dev/null || echo 0))) -gt $MAX_AGE ]; then
# Fetch only the temperature format (%t) from wttr.in silently
TEMP=$(curl -s "wttr.in/?format=%t")
# Update cache only if curl returned a valid result
if [ -n "$TEMP" ]; then
echo "$TEMP" > "$CACHE_FILE"
fi
fi
# Read and output from the cache file
cat "$CACHE_FILE"Offline


By default, it geolocates your IP and uses that to determine your weather. From https://github.com/chubin/wttr.in:
If you omit the location name, you will get the report for your current location based on your IP address.
Does the original script work for you again?
Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline


Hi, ToZ. No, the original script still won't cache. I tried the original script on another computer and no-go on the cache.
Offline


It works for me if I use the original curl command (the one that's commented out in your script above). wxdata-cached never gets created because the curl command is actually saved to a variable (OUT). If you want to direct the output to a file, you should use "curl -o ${wxcache}", but then the script won't work because you've directed the output to a file and the script is processing the variable.
The curl command should be:
OUT=$(curl -s wttr.is/$LATITUDE,$LONGITUDE?format="%C\n%h\n%t\n%f\n%w\n%l\n%m\n%M\n%p\n%P\n%D\n%S\n%z\n%s\n%d\n%C\n&?u")...for this script to work. Note: I've also changed wttr.in to wttr.is, as this is now the recommended location to use for scripts.
Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline


Strange. I returned to your original command and both files in ${HOME}/tmp/ remain empty upon refresh and so unable to use the cached output when wifi is disabled.
I had edited the curl command to pare down the output to just numerical temperature, no icons, no leading plus sign, since 14.04 didn't have the noto fonts, etc, and even using a text print-out of weather condition (eg Sunny), the weather condition font size and temperature font size, I couldn't get them to match.
AI's script, though not as elegant as yours, continues to cache, and I was able to crib from yours and set up longitude and latitude criteria as that was more accurate than zip code or even city+state.
I also had to move the cache file out of /tmp to ${HOME}/tmp/ as the slow-to-connect wifi connection at initial desktop made the genmon throw an error, since it was searching /tmp for a cache file that wasn't yet created. Now the cached temperature remains persistent even after reboot.
I've taken your advice and changed wttr.in to wttr.is. which produces the same temperature either way.
But one thing I've noticed is that wttr.* can be off by as much as 4 degrees F compared to weather on phone or internet or Rainlendar, even with the more exact long/lat settings.
I'm guessing that's b/c of a 60-minute refresh rate at the wttr mothership, or some other lag, but I wouldn't know for certain.
#!/bin/bash
SITE="Wheaton"
LATITUDE="39.0398"
LONGITUDE="-77.0553"
CACHE_FILE="${HOME}/tmp/wttr_temp.txt"
MAX_AGE=300 # Cache time in seconds (5 minutes)
# Check if cache file exists and is newer than MAX_AGE
if [ ! -f "$CACHE_FILE" ] || [ $(($(date +%s) - $(stat -c %Y "$CACHE_FILE" 2>/dev/null || echo 0))) -gt $MAX_AGE ]; then
# Fetch only the temperature format (%t) from wttr.in silently
TEMP=$(curl -s "wttr.is/$LATITUDE,$LONGITUDE?format=%t" | sed 's/+//g')
# Update cache only if curl returned a valid result
if [ -n "$TEMP" ]; then
echo "$TEMP" > "$CACHE_FILE"
fi
fi
# Read and output from the cache file
cat "$CACHE_FILE"Offline


Strange. I returned to your original command and both files in ${HOME}/tmp/ remain empty upon refresh and so unable to use the cached output when wifi is disabled.
If you want to cache the output, for when the site doesn't respond, try this version of the script:
#!/bin/bash
[[ ! $(curl -s -o /dev/null -w "%{http_code}" wttr.is) -eq 200 ]] && exit 1
wxcache=${HOME}/tmp/wxdata-cached
SITE="Wheaton"
LATITUDE="39.0398"
LONGITUDE="-77.0553"
CLICK_COMMAND="xfce4-terminal -H --geometry=126x41 -T "Weather" -x curl -s wttr.in/$LATITUDE,$LONGITUDE"
##CLICK_COMMAND="xfce4-terminal -H -- font "BoldSystem.ttf 16" --geometry=126x41 -T "Weather" -x curl -s wttr.in/$LATITUDE,$LONGITUDE"
function toDate
{
HOUR=$(echo $1 | awk -F':' '{print $1}')
MINUTE=$(echo $1 | awk -F':' '{print $2}')
case $HOUR in
"00") HOUR="12" AMPM="am" ;;
"01") HOUR="1" AMPM="am" ;;
"02") HOUR="2" AMPM="am" ;;
"03") HOUR="3" AMPM="am" ;;
"04") HOUR="4" AMPM="am" ;;
"05") HOUR="5" AMPM="am" ;;
"06") HOUR="6" AMPM="am" ;;
"07") HOUR="7" AMPM="am" ;;
"08") HOUR="8" AMPM="am" ;;
"09") HOUR="9" AMPM="am" ;;
"10") HOUR="10" AMPM="am" ;;
"11") HOUR="11" AMPM="am" ;;
"12") HOUR="12" AMPM="am" ;;
"13") HOUR="1" AMPM="pm" ;;
"14") HOUR="2" AMPM="pm" ;;
"15") HOUR="3" AMPM="pm" ;;
"16") HOUR="4" AMPM="pm" ;;
"17") HOUR="5" AMPM="pm" ;;
"18") HOUR="6" AMPM="pm" ;;
"19") HOUR="7" AMPM="pm" ;;
"20") HOUR="8" AMPM="pm" ;;
"21") HOUR="9" AMPM="pm" ;;
"22") HOUR="10" AMPM="pm" ;;
"23") HOUR="11" AMPM="pm" ;;
esac
echo "$HOUR:$MINUTE $AMPM"
}
OUT=$(curl -s wttr.is/$LATITUDE,$LONGITUDE?format="%C\n%h\n%t\n%f\n%w\n%l\n%m\n%M\n%p\n%P\n%D\n%S\n%z\n%s\n%d\n%C\n&?u")
echo $OUT > $wxcache
WEATHERICON=$(echo $OUT | awk '{print $1}')
HUMIDITY=$(echo $OUT | awk '{print $2}')
TEMPERATURE=$(echo $OUT | awk '{print $3}' | sed -e 's/+//g' | sed -e 's/^-0/0/g' )
FEELSLIKE=$(echo $OUT | awk '{print $4}' | sed -e 's/+//g' | sed -e 's/^-0/0/g' )
WIND=$(echo $OUT | awk '{print $5}')
LOCATION=$(echo $OUT | awk '{print $6}')
MOONPHASE=$(echo $OUT | awk '{print $7}')
MOONDAY=$(echo $OUT | awk '{print $8}')
PRECIPITATION=$(echo $OUT | awk '{print $9}')
PRESSURE=$(echo $OUT | awk '{print $10}')
DAWN=$(toDate "$(echo $OUT | awk '{print $11}')")
SUNRISE=$(toDate "$(echo $OUT | awk '{print $12}')")
ZENITH=$(toDate "$(echo $OUT | awk '{print $13}')")
SUNSET=$(toDate "$(echo $OUT | awk '{print $14}')")
DUSK=$(toDate "$(echo $OUT | awk '{print $15}')")
WEATHERCONDITION=$(echo $OUT | awk '{print $16" "$17" "$18}')
if [ "$1" == "debug" ]; then
echo "OUT=$OUT"
echo "WEATHERICON=$WEATHERICON"
echo "HUMIDITY=$HUMIDITY"
echo "TEMPERATURE=$TEMPERATURE"
echo "FEELSLIKE=$FEELSLIKE"
echo "WIND=$WIND"
echo "LOCATION=$LOCATION"
echo "MOONPHASE=$MOONPHASE"
echo "MOONDAY=$MOONDAY"
echo "PRECIPITATION=$PRECIPITATION"
echo "PRESSURE=$PRESSURE"
echo "DAWN=$DAWN"
echo "SUNRISE=$SUNRISE"
echo "ZENITH=$ZENITH"
echo "SUNSET=$SUNSET"
echo "DUSK=$DUSK"
echo "WEATHERCONDITION=$WEATHERCONDITION"
fi
#do the genmon
echo -e "<txt><span size='x-large'>$WEATHERICON</span><span rise='3000'> $TEMPERATURE</span></txt>"
echo -e "<txtclick>$CLICK_COMMAND</txtclick>"
echo -e "<tool><span font_desc='Bold 16'>$WEATHERICON</span> <b><big>$SITE</big></b>
$TEMPERATURE <small>and</small> $WEATHERCONDITION
<small>
Feels like:\t$FEELSLIKE
Humidity:\t$HUMIDITY
Wind:\t\t$WIND
Precipitation:\t$PRECIPITATION
Pressure:\t$PRESSURE
Rise/Set:\t$SUNRISE / $SUNSET
Moon:\t\t$MOONPHASE
</small>
<span size='x-small'>$(date)</span></tool>"
exit 0...I've added a test at the top of the script that if the website doesn't respond, the script exits - this should keep the cached data and not overwrite it. I've also added an echo command below to echo the output to your cache file. Hopefully this should work for you.
But one thing I've noticed is that wttr.* can be off by as much as 4 degrees F compared to weather on phone or internet or Rainlendar, even with the more exact long/lat settings.
Yeah, each of the different weather services seem to provide different information I've noticed. I think its related to the time of the measurement and which actual weather measurement stations they use.
Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline


Hello,
Less complete than ToZ script, but you need only one command in genmon :
sh -c 'ansiweather -a false -s true | cut -d " " -f 6-24'
EndeavourOS
Xfce+gtk3-classic (no CSD)+Picom
Offline


ToZ, many thanks for the revamped script, but while there is successful caching in ${HOME}/tmp/wxdata-cached, the script still won't access ${HOME}/tmp/wxdata-cached when wifi is disabled.
More importantly, given the substantial lag of wttr.*, is there another weather service that could generate more current conditions?
@ gogogadget -- I appreciate you weighing in. Your command is great, but given my 4.8-inch screen, I'm getting too much information for a panel output. Any chance it could print only the current temperature?
Also, how did you get ansiweather to work? A sign-up API? And do you find it more accurate than wttr.*?
My thanks to you both.
Offline


ToZ, many thanks for the revamped script, but while there is successful caching in ${HOME}/tmp/wxdata-cached, the script still won't access ${HOME}/tmp/wxdata-cached when wifi is disabled.
Right, the logic is wrong. Sorry about that. Try this version:
#!/bin/bash
wxcache=${HOME}/tmp/wxdata-cached
SITE="Wheaton"
LATITUDE="39.0398"
LONGITUDE="-77.0553"
CLICK_COMMAND="xfce4-terminal -H --geometry=126x41 -T "Weather" -x curl -s wttr.in/$LATITUDE,$LONGITUDE"
##CLICK_COMMAND="xfce4-terminal -H -- font "BoldSystem.ttf 16" --geometry=126x41 -T "Weather" -x curl -s wttr.in/$LATITUDE,$LONGITUDE"
function toDate
{
HOUR=$(echo $1 | awk -F':' '{print $1}')
MINUTE=$(echo $1 | awk -F':' '{print $2}')
case $HOUR in
"00") HOUR="12" AMPM="am" ;;
"01") HOUR="1" AMPM="am" ;;
"02") HOUR="2" AMPM="am" ;;
"03") HOUR="3" AMPM="am" ;;
"04") HOUR="4" AMPM="am" ;;
"05") HOUR="5" AMPM="am" ;;
"06") HOUR="6" AMPM="am" ;;
"07") HOUR="7" AMPM="am" ;;
"08") HOUR="8" AMPM="am" ;;
"09") HOUR="9" AMPM="am" ;;
"10") HOUR="10" AMPM="am" ;;
"11") HOUR="11" AMPM="am" ;;
"12") HOUR="12" AMPM="am" ;;
"13") HOUR="1" AMPM="pm" ;;
"14") HOUR="2" AMPM="pm" ;;
"15") HOUR="3" AMPM="pm" ;;
"16") HOUR="4" AMPM="pm" ;;
"17") HOUR="5" AMPM="pm" ;;
"18") HOUR="6" AMPM="pm" ;;
"19") HOUR="7" AMPM="pm" ;;
"20") HOUR="8" AMPM="pm" ;;
"21") HOUR="9" AMPM="pm" ;;
"22") HOUR="10" AMPM="pm" ;;
"23") HOUR="11" AMPM="pm" ;;
esac
echo "$HOUR:$MINUTE $AMPM"
}
if [ $(curl -s -o /dev/null -w "%{http_code}" wttr.is) -eq 200 ]; then
OUT=$(curl -s wttr.is/$LATITUDE,$LONGITUDE?format="%C\n%h\n%t\n%f\n%w\n%l\n%m\n%M\n%p\n%P\n%D\n%S\n%z\n%s\n%d\n%C\n&?u")
echo $OUT > $wxcache
else
OUT="$(cat $wxcache)"
fi
WEATHERICON=$(echo $OUT | awk '{print $1}')
HUMIDITY=$(echo $OUT | awk '{print $2}')
TEMPERATURE=$(echo $OUT | awk '{print $3}' | sed -e 's/+//g' | sed -e 's/^-0/0/g' )
FEELSLIKE=$(echo $OUT | awk '{print $4}' | sed -e 's/+//g' | sed -e 's/^-0/0/g' )
WIND=$(echo $OUT | awk '{print $5}')
LOCATION=$(echo $OUT | awk '{print $6}')
MOONPHASE=$(echo $OUT | awk '{print $7}')
MOONDAY=$(echo $OUT | awk '{print $8}')
PRECIPITATION=$(echo $OUT | awk '{print $9}')
PRESSURE=$(echo $OUT | awk '{print $10}')
DAWN=$(toDate "$(echo $OUT | awk '{print $11}')")
SUNRISE=$(toDate "$(echo $OUT | awk '{print $12}')")
ZENITH=$(toDate "$(echo $OUT | awk '{print $13}')")
SUNSET=$(toDate "$(echo $OUT | awk '{print $14}')")
DUSK=$(toDate "$(echo $OUT | awk '{print $15}')")
WEATHERCONDITION=$(echo $OUT | awk '{print $16" "$17" "$18}')
if [ "$1" == "debug" ]; then
echo "OUT=$OUT"
echo "WEATHERICON=$WEATHERICON"
echo "HUMIDITY=$HUMIDITY"
echo "TEMPERATURE=$TEMPERATURE"
echo "FEELSLIKE=$FEELSLIKE"
echo "WIND=$WIND"
echo "LOCATION=$LOCATION"
echo "MOONPHASE=$MOONPHASE"
echo "MOONDAY=$MOONDAY"
echo "PRECIPITATION=$PRECIPITATION"
echo "PRESSURE=$PRESSURE"
echo "DAWN=$DAWN"
echo "SUNRISE=$SUNRISE"
echo "ZENITH=$ZENITH"
echo "SUNSET=$SUNSET"
echo "DUSK=$DUSK"
echo "WEATHERCONDITION=$WEATHERCONDITION"
fi
#do the genmon
echo -e "<txt><span size='x-large'>$WEATHERICON</span><span rise='3000'> $TEMPERATURE</span></txt>"
echo -e "<txtclick>$CLICK_COMMAND</txtclick>"
echo -e "<tool><span font_desc='Bold 16'>$WEATHERICON</span> <b><big>$SITE</big></b>
$TEMPERATURE <small>and</small> $WEATHERCONDITION
<small>
Feels like:\t$FEELSLIKE
Humidity:\t$HUMIDITY
Wind:\t\t$WIND
Precipitation:\t$PRECIPITATION
Pressure:\t$PRESSURE
Rise/Set:\t$SUNRISE / $SUNSET
Moon:\t\t$MOONPHASE
</small>
<span size='x-small'>$(date)</span></tool>"
exit 0This version first checks to see if the website is available, and if so, uses curl to grab the weather info. If the website is not available, it uses the cached file. Give it a try and let me know how it works.
Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline


Any chance it could print only the current temperature?
Like this :
sh -c 'ansiweather -a false -s true | cut -d " " -f 6-8'
EndeavourOS
Xfce+gtk3-classic (no CSD)+Picom
Offline


ToZ -- great, that works, that caches.
@ gogogadget I had to jiggle a couple of handles, but got a temperature without space between the number and degree symbol:
ansiweather -l "Glenmont,US" -u imperial -a false -s true | cut -d " " -f 5-6 | sed 's/ °F/°F/g'I put the ansiweather command in place of wttr and it's a LITTLE bit more accurate for temperature, though still off compared to the read-outs of phone, internet, and rainlendar. I suppose I should just put a thermometer outside my abode to be certain.
I'm marking this as solved, and again, thank you very much, the both of you.
It would be interesting, I think, to see what other xfce users find to be the most accurate weather service.
Offline
[ Generated in 0.018 seconds, 7 queries executed - Memory usage: 640.16 KiB (Peak: 673.13 KiB) ]