Skip to content

Instantly share code, notes, and snippets.

@scmx
Created March 4, 2015 11:36
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 scmx/0985b2d8a85314a10d26 to your computer and use it in GitHub Desktop.
Save scmx/0985b2d8a85314a10d26 to your computer and use it in GitHub Desktop.
Is the internet on fire? OSX Notification

Have you seen the excellent https://istheinternetonfire.com/ website?

They provide a nice dns txt api that I decided to use the give myself an OSX notification whenever they update.

img

Save the following to a file somewhere in your $PATH. I chose .bin/istheinternetonfire

#!/usr/bin/env bash

cache_file="$HOME/.istheinternetonfire_dig_cache"

[ -f $cache_file ] || touch $cache_file;

cached_dig="$(cat $cache_file)"
current_dig="$(dig +short txt istheinternetonfire.com)"

echo "$current_dig" > $cache_file

if [[ "$cached_dig" == "$current_dig" ]]; then
  exit 0;
fi

message=$(echo $current_dig | tr \" \ )

terminal-notifier-notify \
  -message "$message" \
  -title "Is the internet on fire?" \
  -open "http://istheinternetonfire.com"

Open crontab -e and add there a cronjob that runs this command regularly

PATH=/Users/albert/.rbenv/shims:/Users/albert/.bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

# display an osx notification if "istheinternetonfire.com" has an update
0 * * * * $HOME/.bin/istheinternetonfire

It will only show a notification if something has changed

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