Skip to content

Instantly share code, notes, and snippets.

@onjin
Last active December 16, 2015 01:09
Show Gist options
  • Save onjin/5353298 to your computer and use it in GitHub Desktop.
Save onjin/5353298 to your computer and use it in GitHub Desktop.
Some bitcoins data for conky panel
#!/bin/bash
# put jsgrep into ~/bin
# wget https://gist.github.com/onjin/5353305
#
# crontab:
# * * * * ~/path/to/conkybtc
#
# .conkyrc:
# ${execpi 30 cat .conkybtc }
#
API_KEY="your-bitcoin.cz-api-key"
WORKER_NAME="worker.name"
BUF="/home/`whoami`/.conkybtc"
HSTYLE="\${font DejaVuSansMono:size=8.5}\${color red}"
DSTYLE="\${font DejaVuSansMono:size=8.5:style=bold}\${color white}"
SMALL="\${font DejaVuSansMono:size=7}"
DIFF=`curl -s http://blockexplorer.com/q/getdifficulty`
BLK=`curl -s http://blockexplorer.com/q/getblockcount`
GOX=( `curl -s https://data.mtgox.com/api/2/BTCUSD/money/ticker | ~/bin/jsgrep data "avg|vol" "value$"|tr -d \"` )
_NR="`curl -s http://blockexplorer.com/q/estimate`*0.007158278"
_NXT=`curl -s http://blockexplorer.com/q/nextretarget`
NETHASH="`echo $_NR | bc`"
NXT=$(($_NXT-$BLK))
CZ=( `curl -s https://mining.bitcoin.cz/accounts/profile/json/${API_KEY} | ~/bin/jsgrep "confirmed_reward|unconfirmed_reward|hashrate"|tr -d \"` )
HASH=( `curl -s https://mining.bitcoin.cz/accounts/profile/json/${API_KEY} | ~/bin/jsgrep workers ${WORKER_NAME} hashrate|tr -d \"` )
echo "BITCOIN \${hr 2}" > $BUF
echo "BlockCount\${alignr}$BLK" >> $BUF
echo "Diffculty\${alignr}${DIFF%%.*}" >> $BUF
echo "Last Price\${alignr}${GOX[1]%%.*} USD" >> $BUF
echo "Volume BTC/24h\${alignr}${GOX[0]%%.*}" >> $BUF
echo >> $BUF
echo "MINING \${hr 2}" >> $BUF
echo "ConfReward\${alignr}${CZ[0]}" >> $BUF
echo "UncoReward\${alignr}${CZ[1]}" >> $BUF
echo "HashRate\${alignr}${HASH} Mh/s" >> $BUF
echo >> $BUF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment