enkore/i3pystatus — pull request #83 by crwood (2014-07-17 06:20:00+00:00)
Title: Bitcoin module

Here's a Bitcoin module that I wrote to track market prices and/or blockchain data. With the default format string, it functions like a traditional stock-ticker (showing the current market value of 1 BTC in USD) but also provides functionality to calculate wallet balances from a list of addresses, monitor wallet addresses for incoming/outgoing transactions, change colors/indicators on price increase/decrease, and so on.

Here's an example configuration:

```python
# Check the BTC price once per minute, displaying green (and with an
# upward status triangle) if the price has risen since the last check
# or red (with a downward triangle) if it has decreased.
status.register("bitcoin",
format="{status}{last_price}",
colorize=True,
interval=60,)

# Monitor the three separate wallet addresses, displaying their combined
# total balance in both BTC and USD. Checks every 10 minutes by default.
status.register("bitcoin",
format="Balance: ฿{balance_btc} ${balance_fiat}",
wallet_addresses=[
"1QCKC5WyycXHwYSmnoCBCzq6Z6FcoZe6ar",
"132GuxSVuEhgkh8PKToVKiibdnAd2iKtCE",
"16oFbYEYZtVHjLLZxUz26J17F7ADZ4roHD"],)
```

And the output:

![ss](https://cloud.githubusercontent.com/assets/882430/3609129/d99916fc-0d72-11e4-8ba8-31b6f82f0f79.png)

See the docstrings/code for the other/full details.

Note that I've also added a common function to i3pystatus.core.util (called 'user_open()') that passes a string to the system browser (via webbrowser.open()) if that string is a URL or to the shell (via subprocess.Popen()) if it's not. This is intended to be used in other modules in conjunction with on_leftclick()/on_rightclick() calls, effectively giving the user the ability to define click-events at the configuration-level instead of having to edit the code directly.