Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #dontsurfinthenude.blogspot.com/
- location=wolverhampton,gb
- #try city,country code or look up at openweathermap.org
- data_metric=$(ansiweather -l $location -u metric -s true -a false -d true)
- data_imperial=$(ansiweather -l $location -u imperial -s true -a false -d true)
- #comment out one if you want only metric or only imperial
- data7day=$(ansiweather -l $location -u metric -s true -a false -f 7) #centigrade
- #data7day=$(ansiweather -l $location -u imperial -s true -a false -f 7) #fahrenheit
- city=$(echo "$data_metric" | awk '{print $3}')
- temp=$(echo "$data_metric" | awk '{print $4$5}') #city,temp,°C
- #temp=$(echo "$data_imperial" | awk '{print $5$6}') #city,temp,°F
- symbol=$(echo "$data_metric" | awk '{print $6}')
- #wind=$(echo "$data_metric" | awk '{print $9,$11,$12,$13}') #wind,m/s
- wind=$(echo "$data_imperial" | awk '{print $9,$11,$12,$13}') #wind,mph
- humidity=$(echo "$data_imperial" | awk '{print $15,$17$18}') #humidity
- pressure=$(echo "$data_metric" | awk '{print $20,$22,$23}') #pressure,hPa
- #pressure=$(echo "$data_imperial" | awk '{print $20,$22,$23}') #pressure,inHg
- sunrise=$(echo "$data_metric" | awk '{printf "%7s %.5s %s\n", $23,$26,$27}') #sunrise
- sunset=$(echo "$data_metric" | awk '{printf "%-7s %.5s %s\n", $29,$32,$33}') #sunset
- forecast=$(echo "$data7day" | awk 'BEGIN {format="%s %7s%s %s\n"} #7-day-forcast
- {printf format, $3,$6,$7,$8}
- {printf format, $10,$13,$14,$15}
- {printf format, $17,$20,$21,$22}
- {printf format, $24,$27,$28,$29}
- {printf format, $31,$34,$35,$36}
- {printf format, $38,$41,$42,$43}
- {printf format, $45,$48,$49,$50}')
- PANEL="<txt>$temp</txt>"
- PANEL+="<txtclick>firefox --new-tab --url https://openweathermap.org/city/2633691</txtclick>"
- #PANEL+="<txtclick>xfce4-panel --plugin-event=genmon-*:refresh:bool:true</txtclick>"
- #Replace "*" with the ID number from the XFCE panel - Preferences>Items (Hover)
- #PANEL+="<txtclick>xterm -hold -e ansiweather -l $location -s true -f 7</txtclick>"
- TOOLTIP="<tool>"
- TOOLTIP+="<span weight='bold' font='sans regular'>W E A T H E R</span>\n\n"
- TOOLTIP+="<span font= 'sans regular'>$city</span>\n"
- TOOLTIP+="Now: $temp $symbol\n\n"
- #TOOLTIP+="<span font= 'sans regular'>$wind</span>\n"
- #TOOLTIP+="<span font= 'sans regular'>$humidity</span>\n"
- #TOOLTIP+="<span font= 'sans regular'>$pressure</span>\n\n"
- TOOLTIP+="<span font= 'monospace regular'>$forecast</span>\n\n"
- TOOLTIP+="<span font= 'sans regular'>$sunrise</span>\n"
- TOOLTIP+="<span font= 'sans regular'>$sunset</span>\n\n"
- #TOOLTIP+="<span weight='bold' font='sans regular'>Click to update</span>"
- TOOLTIP+="<span weight='bold' font='sans regular'>OpenWeather</span>"
- TOOLTIP+="</tool>"
- if [[ -z "$data7day" || "$data7day" == "ERROR: Cannot fetch weather data" ]]; then
- echo "<icon>network-offline</icon>"
- echo "<tool>No Internet</tool>"
- else
- echo -e "${PANEL}"
- echo -e "${TOOLTIP}"
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement