Monacoin 価格通知
前提条件
brew install jq
インストール方法
# Download script file
curl -sSo /usr/local/bin/monacoin https://gist.githubusercontent.com/hanksudo/044b9b4b3d10289484190ff5568c4db7/raw/monacoin.sh
# Give executable permission
chmod +x /usr/local/bin/monacoin
または、自分で /usr/local/bin/monacoin
を作成する
monacoin.sh
#/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
# speak
say "monacoin $MONA"
使い方
$ monacoin
85.6
3時間ごとに実行する - launchagents
~/Library/LaunchAgents/monacoin.price.plist
<?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>
起動
launchctl setenv PATH /usr/local/bin:$PATH
launchctl load ~/Library/LaunchAgents/monacoin.price.plist