Hourly price notifications on Linux

0

I'm running Debian & Ubuntu and I've been using this script running in a terminal for a while but I find I easily get obsessed with the price. Instead I'd rather get, say hourly, desktop notifications.

Is there a simple way to do this?

erb

Posted 2014-01-09T10:11:44.760

Reputation: 111

Question was closed 2014-02-09T21:15:21.650

4This question appears to be off-topic because it is about some particular script, not crytocurrencies in generalSalvador Dali 2014-01-10T00:34:24.563

Agreed, this is technically programming so it might be better suited for http://stackoverflow.com.

Greg Hewgill 2014-01-10T07:15:35.237

I was initially looking for a premade solution, the answer became programming-oriented when I couldn't find any. The question was never about the script, it was just some background to my question.erb 2014-01-10T08:53:25.467

Answers

-1

I modified the script and used notify-send to get what I wanted. I run the lightweight notification daemon xfce4-notifyd but most desktop environments (Gnome, KDE, Xfce) should have one preinstalled (for example Gnome's notification-daemon).

It depends on the jq command, so make sure you install it first using your package manager.

Here's the script:

#!/bin/sh
# Requires jq

# Remember to chmod +x!
#
# Add the following cron-job (using "crontab -e") to run at hourly intervals:
#     0 * * * * export DISPLAY=:0.0 && /bin/bash <SCRIPT_PATH_GOES_HERE> > /dev/null 2>&1
# Change <SCRIPT_PATH_GOES_HERE> to the appropriate name

BTCE_PRICE="$(curl -s https://btc-e.com/api/2/btc_usd/ticker | jq '.ticker.last')"
MTGOX_PRICE="$(curl -s http://data.mtgox.com/api/2/BTCUSD/money/ticker_fast | jq '.data.last.display' | cut -d "\"" -f 2)"

notify-send "MtGox:     $MTGOX_PRICE
BTC-e:      \$$BTCE_PRICE"

Also available here

In order to run it on hourly intervals add the following line to your crontab using crontab -e:

0 * * * * export DISPLAY=:0.0 && /bin/bash <SCRIPT_PATH_GOES_HERE> > /dev/null 2>&1

erb

Posted 2014-01-09T10:11:44.760

Reputation: 111

0

Assuming your script is called btce_ticker.sh, the following line would do it:

while true; do btce_ticker.sh; sleep 3600; done

The sleep 3600 sleeps for an hour before looping around and running the script again.

Greg Hewgill

Posted 2014-01-09T10:11:44.760

Reputation: 3 321

I don't want a terminal notification, instead I'd like a desktop notification. I solved it but can't answer my own question yet (apparently a forced 8h delay) since I have <10 rep. The script is here however: https://gist.github.com/ErikBjare/8332113

erb 2014-01-09T10:36:44.843

@erb: I note that you didn't actually say "desktop" in your original question.Greg Hewgill 2014-01-09T20:04:01.603

Yeah I forgot to mention that, sorry.erb 2014-01-09T20:10:02.777