Skip to content

Instantly share code, notes, and snippets.

@sunng87
Last active August 21, 2018 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sunng87/fd780cfd41c78bba98c1 to your computer and use it in GitHub Desktop.
Save sunng87/fd780cfd41c78bba98c1 to your computer and use it in GitHub Desktop.
i3blocks openweathermap

openweathermap for i3blocks

dependencies

  • i3blocks
  • httpie
  • jq
  • ttf-font-icons (aur)

configuration

[weather]
interval=3600
instance=beijing
command=path/to/weather.sh
#!/bin/bash
# Copyright (C) 2016 Ning Sun <sunng@about.me>
# 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"
@carc1n0gen
Copy link

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

@carc1n0gen
Copy link

carc1n0gen commented Nov 15, 2016

For some reason, even after a reboot my i3blocks wasn't liking httpie. Switching to curl worked ¯\(ツ)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment