taffybar-4.0.2: A desktop bar similar to xmobar, but with more GUI

Copyright | (c) Ivan A. Malison
License | BSD3-style (see LICENSE)
Maintainer | Ivan A. Malison
Stability | unstable
Portability | unportable
Safe Haskell | Safe-Inferred
Language | Haskell2010

System.Taffybar.Widget.Crypto

Description

This module provides widgets for tracking the price of crypto currency assets.

Synopsis

- cryptoPriceLabelWithIcon :: forall a. KnownSymbol a => TaffyIO Widget
- newtype CMCAPIKey = CMCAPIKey String
- setCMCAPIKey :: String -> TaffyIO CMCAPIKey
- cryptoPriceLabel :: forall a. KnownSymbol a => TaffyIO Widget
- cryptoPriceLabel' :: CryptoPriceChannel a -> TaffyIO Widget
- cryptoIconsDir :: IO FilePath
- pathForCryptoSymbol :: String -> IO FilePath
- getCryptoPixbuf :: String -> TaffyIO (Maybe Pixbuf)
- getCryptoIconFromCache :: MonadIO m => String -> m (Maybe Pixbuf)
- getCryptoIconFromCMC :: String -> TaffyIO (Maybe Pixbuf)
- getCryptoIconFromCMC' :: String -> String -> IO (Maybe Pixbuf)
- getIconURIFromJSON :: String -> ByteString -> Maybe Text

# Documentation

cryptoPriceLabelWithIcon :: forall a. KnownSymbol a => TaffyIO Widget Source #

Extends `cryptoPriceLabel` with an icon corresponding to the symbol of the purchase crypto that will appear to the left of the price label. See the docstring for `getCryptoPixbuf` for details about how this icon is retrieved. Note that automatic icon retrieval requires a coinmarketcap api key to be set at taffybar startup. As with `cryptoPriceLabel`, this function must be invoked with a type application with the type string that expresses the symbol of the relevant token and the underlying currency in which its price should be expressed. See the docstring of `cryptoPriceLabel` for details about the exact format that this string should take.

newtype CMCAPIKey Source #

Constructors

CMCAPIKey String |

setCMCAPIKey :: String -> TaffyIO CMCAPIKey Source #

Set the coinmarketcap.com api key that will be used for retrieving crypto icons that are not cached. This should occur before any attempts to retrieve crypto icons happen. The easiest way to call this appropriately is to set it as a `startupHook`.

cryptoPriceLabel :: forall a. KnownSymbol a => TaffyIO Widget Source #

Build a label that will reflect the price of some token in some currency in the coingecko API. This function accepts these valuesas a type parameter with kind `Value` of the form `(symbol for asset being purchased)-(currency the price should be expressed in)`. For example, the product string for the price of bitcoin quoted in U.S. dollars is "BTC-USD". You can invoke this function by enabling the TypeApplications language extension and passing the string associated with the asset that you want to track as follows:

    cryptoPriceLabel @"BTC-USD"

cryptoPriceLabel' :: CryptoPriceChannel a -> TaffyIO Widget Source #

cryptoIconsDir :: IO FilePath Source #

pathForCryptoSymbol :: String -> IO FilePath Source #

getCryptoPixbuf :: String -> TaffyIO (Maybe Pixbuf) Source #

Retrieve a pixbuf image corresponding to the provided crypto symbol. The image used will be retrieved from the file with the name `(pricesymbol).png` from the directory defined by `cryptoIconsDir`. If a file is not found there and an an api key for coinmarketcap.com has been set using `setCMCAPIKey`, an icon will be automatically be retrieved from coinmarketcap.com.

getCryptoIconFromCache :: MonadIO m => String -> m (Maybe Pixbuf) Source #

getCryptoIconFromCMC :: String -> TaffyIO (Maybe Pixbuf) Source #

getCryptoIconFromCMC' :: String -> String -> IO (Maybe Pixbuf) Source #

getIconURIFromJSON :: String -> ByteString -> Maybe Text Source #