Skip to content

Instantly share code, notes, and snippets.

@danking
Last active December 18, 2015 20:59
Show Gist options
  • Select an option

  • Save danking/5844659 to your computer and use it in GitHub Desktop.

Select an option

Save danking/5844659 to your computer and use it in GitHub Desktop.
Beijing Air Quality Formatter for xmobar
#!/bin/zsh
AQI=$(curl -s http://iphone.bjair.info/m/beijing/mobile \
| grep -E '<h1>[0-9]+</h1>' \
| sed 's:.*<h1>\([0-9]*\)</h1>.*:\1:')
if [[ $AQI -lt 50 ]]; then
echo -n "<fc=green>"
elif [[ $AQI -lt 100 ]]; then
echo -n "<fc=yellow>"
elif [[ $AQI -lt 150 ]]; then
echo -n "<fc=orange>"
elif [[ $AQI -lt 200 ]]; then
echo -n "<fc=red>"
elif [[ $AQI -lt 300 ]]; then
echo -n "<fc=purple>"
else
echo -n "<fc=#ff7298>"
fi
echo "$AQI</fc>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment