mirror of
https://github.com/d3m0k1d/dots.git
synced 2026-03-15 02:12:43 +00:00
Add my dots
This commit is contained in:
24
.config/waybar/scripts/weather.sh
Executable file
24
.config/waybar/scripts/weather.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
BSSIDS="$(nmcli device wifi list |
|
||||
awk 'NR>1 {if ($1 != "*") {print $1}}' |
|
||||
tr -d ":" |
|
||||
tr "\n" ",")"
|
||||
|
||||
LOC=""
|
||||
REQUEST_GEO="$(wget -qO - http://openwifi.su/api/v1/bssids/"$BSSIDS")"
|
||||
if [[ "$(jq ".count_results" <<< "$REQUEST_GEO")" -gt 0 ]] ; then
|
||||
LAT="$(jq ".lat" <<< "$REQUEST_GEO")"
|
||||
LON="$(jq ".lon" <<< "$REQUEST_GEO")"
|
||||
LOC="$LAT,$LON"
|
||||
fi
|
||||
|
||||
text="$(curl -s "https://wttr.in/$LOC?format=1" | sed 's/ //g')"
|
||||
tooltip="$(curl -s "https://wttr.in/$LOC?0QT" |
|
||||
sed 's/\\/\\\\/g' |
|
||||
sed ':a;N;$!ba;s/\n/\\n/g' |
|
||||
sed 's/"/\\"/g')"
|
||||
|
||||
if ! grep -q "Unknown location" <<< "$text"; then
|
||||
echo "{\"text\": \"$text\", \"tooltip\": \"<tt>$tooltip</tt>\", \"class\": \"weather\"}"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user