Skip to content

Instantly share code, notes, and snippets.

@hanksudo
Last active October 8, 2017 11:00
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 hanksudo/044b9b4b3d10289484190ff5568c4db7 to your computer and use it in GitHub Desktop.
Save hanksudo/044b9b4b3d10289484190ff5568c4db7 to your computer and use it in GitHub Desktop.
Monacoin price notifier

Monacoin price notifier

Prerequisites

brew install jq

Installation

curl -sSo /usr/local/bin/monacoin https://gist.githubusercontent.com/hanksudo/044b9b4b3d10289484190ff5568c4db7/raw/monacoin.sh && chmod +x /usr/local/bin/monacoin

Or create file /usr/local/bin/monacoin by yourself.

Usage

/usr/local/bin/monacoin
84

Execute every 3 hours by launchagents

Add plist file to ~/Library/LaunchAgents/

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>monacoin.price</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/bin/monacoin</string>
    </array>
    <key>StartInterval</key>
    <integer>60 * 60 * 3</integer>
    <key>RunAtLoad</key>
    <true/>
    <key>StandardOutPath</key>
    <string>/tmp/monacoin.out</string>
    <key>StandardErrorPath</key>
    <string>/tmp/monacoin.err</string>
</dict>
</plist>

Set to launchagents

launchctl setenv PATH /usr/local/bin:$PATH
launchctl load ~/Library/LaunchAgents/monacoin.price.plist
#/bin/sh
# $ monacoin
# 85.6
# Get price
MONA=`curl -s https://api.zaif.jp/api/1/last_price/mona_jpy | jq .last_price`
# macOS notifier
osascript -e "display notification \"$MONA\" with title \"Monacoin\""
# print
echo $MONA
# speaking
say "monacoin $MONA"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment