Skip to content

Instantly share code, notes, and snippets.

@vivien
Created March 13, 2014 19:50
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 vivien/9535576 to your computer and use it in GitHub Desktop.
Save vivien/9535576 to your computer and use it in GitHub Desktop.
i3blocks script for weather in Canada
#!/bin/sh
# Copyright (C) 2014 Julien Bonjean <julien@bonjean.info>
# 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/>.
#set -x
CITY="${1:-qc-147}"
wget -q "http://weather.gc.ca/rss/city/${CITY}_e.xml" -O - |
# remove namespace
sed 's/<feed .*$/<feed>/g' |
# retrieve feed entry for current conditions
xmllint --debug --xpath 'string(/feed/entry[starts-with(title,"Current Conditions")]/summary)' - |
# remove HTML tags
sed 's/<[^>]\+>//g' |
# remove invalid symbols
sed 's/&deg;C//' |
# extract the data and display
awk '/Condition:/ {$1="";cond=substr($0,2)} /Temperature:/ {temp1=$2} /Wind Chill:/ {temp2=$3} /Observed at:/ {date=$6" "$7} END {print cond": "temp1"°C/"temp2"°C ("date")"}'
Copy link

ghost commented Aug 19, 2015

Hey @vivien,

In case you haven't heard, i3blocks is splitting into two repos! i3blocks will now go on to contain the core binary and a set of smallest usable blocklets to provide some beginner functionality. From i3blocks, i3blocks-contrib has now split off to gather the community contributed blocklets in a single repo to make perusing them easier and more convenient. We would be honoured if you would consider submitting your blocklet(s) to the contrib repo.

This change is the core change scheduled for the v1.5 release. Please note that as an artifact of this split, your entry for this blocklet in the core wiki has been removed as has everyone else's. If you would like to submit your blocklet, please review the contrib wiki to understand the workflow of i3blocks-contrib.

Please note that this change over is in its early stages, so the process for submission hasn't been completely nailed down. We're hard at work still compiling the two project wikis and documenting all changes and standards. It is very likely that things will still change and we value your input on how that change should occur.

Deepest regrads,

@Nycroth

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