- i3blocks
- httpie
- jq
- ttf-font-icons (aur)
[weather]
interval=3600
instance=beijing
command=path/to/weather.sh
#!/bin/bash | |
# Copyright (C) 2016 Ning Sun <[email protected]> | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. | |
# You should have received a copy of the GNU General Public License | |
# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
CITY=$BLOCK_INSTANCE | |
APPID="...your appkey..." | |
OUTPUT=$(http get http://api.openweathermap.org/data/2.5/weather\?APPID\=${APPID}\&q\=${CITY}\&units\=metric) | |
#echo $APPID | |
#echo $OUTPUT | |
TEMP=$(echo $OUTPUT | jq -r ".main.temp") | |
WEATHER=$(echo $OUTPUT | jq -r ".weather[0].main") | |
case $WEATHER in | |
"Clear"*) | |
WEATHER= | |
;; | |
"Rain"*) | |
WEATHER= | |
;; | |
"Snow"*) | |
WEATHER= | |
;; | |
"Thunderstorm"*) | |
WEATHER= | |
;; | |
esac | |
echo "$WEATHER $TEMP°C" | |
echo "$TEMP°C" |
For some reason, even after a reboot my i3blocks wasn't liking httpie. Switching to curl worked ¯\(ツ)/¯
I can't for the life of me get this script to work. When I run it from the command line, it works perfectly fine. But when run from i3blocks, I get nothing from the api