forked from colonelpanic/dotfiles
[taffybar] Add coinbase pro widgets
This commit is contained in:
parent
018cf09776
commit
be87dc9dee
@ -17,8 +17,9 @@ executable imalison-taffybar
|
|||||||
-- ghc-options: -threaded -g -rtsopts
|
-- ghc-options: -threaded -g -rtsopts
|
||||||
ghc-prof-options: -fprof-auto
|
ghc-prof-options: -fprof-auto
|
||||||
build-depends: base
|
build-depends: base
|
||||||
, X11>=1.8
|
, X11
|
||||||
, bytestring
|
, bytestring
|
||||||
|
, coinbase-pro
|
||||||
, containers
|
, containers
|
||||||
, directory
|
, directory
|
||||||
, filepath
|
, filepath
|
||||||
@ -30,6 +31,8 @@ executable imalison-taffybar
|
|||||||
, hslogger
|
, hslogger
|
||||||
, process
|
, process
|
||||||
, split
|
, split
|
||||||
|
, text
|
||||||
|
, time
|
||||||
, taffybar>=3.2.0
|
, taffybar>=3.2.0
|
||||||
, transformers
|
, transformers
|
||||||
, xdg-basedir
|
, xdg-basedir
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
_: super: {
|
_: super: {
|
||||||
haskellPackages = super.haskellPackages.override (old: {
|
haskellPackages = super.haskellPackages.override (old: {
|
||||||
overrides = super.lib.composeExtensions (old.overrides or (_: _: {})) (self: _: {
|
overrides = super.lib.composeExtensions (old.overrides or (_: _: {})) (self: _: {
|
||||||
|
coinbase-pro = self.callCabal2nix "coinbase-pro" (super.fetchFromGitHub {
|
||||||
|
owner = "IvanMalison";
|
||||||
|
repo = "coinbase-pro";
|
||||||
|
rev = "8ac93b7905150c8cbd6957102a730ecceb8b4dba";
|
||||||
|
sha256 = "0v0xw593xczvvalh24bz37v2zbfz92dhz71f04m08abgphqmjvxq";
|
||||||
|
}) { };
|
||||||
imalison-taffybar =
|
imalison-taffybar =
|
||||||
self.callCabal2nix "imalison-taffybar"
|
self.callCabal2nix "imalison-taffybar"
|
||||||
(
|
(
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
module Main where
|
module Main where
|
||||||
|
|
||||||
|
import qualified CoinbasePro.Environment as CB
|
||||||
|
import qualified CoinbasePro.Headers as CB
|
||||||
|
import qualified CoinbasePro.Request as CB
|
||||||
|
import qualified CoinbasePro.Types as CB
|
||||||
|
import qualified CoinbasePro.Unauthenticated.API as CB
|
||||||
import Control.Exception.Base
|
import Control.Exception.Base
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Control.Monad.IO.Class
|
import Control.Monad.IO.Class
|
||||||
@ -11,10 +16,13 @@ import Data.List
|
|||||||
import Data.List.Split
|
import Data.List.Split
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
|
import qualified Data.Text
|
||||||
|
import Data.Time
|
||||||
import Network.HostName
|
import Network.HostName
|
||||||
import StatusNotifier.Tray
|
import StatusNotifier.Tray
|
||||||
import System.Directory
|
import System.Directory
|
||||||
import System.Environment
|
import System.Environment
|
||||||
|
import System.Environment.XDG.BaseDir
|
||||||
import System.FilePath.Posix
|
import System.FilePath.Posix
|
||||||
import System.IO
|
import System.IO
|
||||||
import System.Log.Handler.Simple
|
import System.Log.Handler.Simple
|
||||||
@ -30,7 +38,6 @@ import System.Taffybar.Information.CPU
|
|||||||
import System.Taffybar.Information.EWMHDesktopInfo
|
import System.Taffybar.Information.EWMHDesktopInfo
|
||||||
import System.Taffybar.Information.Memory
|
import System.Taffybar.Information.Memory
|
||||||
import System.Taffybar.Information.X11DesktopInfo
|
import System.Taffybar.Information.X11DesktopInfo
|
||||||
import System.Environment.XDG.BaseDir
|
|
||||||
import System.Taffybar.SimpleConfig
|
import System.Taffybar.SimpleConfig
|
||||||
import System.Taffybar.Util
|
import System.Taffybar.Util
|
||||||
import System.Taffybar.Widget
|
import System.Taffybar.Widget
|
||||||
@ -41,6 +48,14 @@ import System.Taffybar.Widget.Workspaces
|
|||||||
import Text.Printf
|
import Text.Printf
|
||||||
import Text.Read hiding (lift)
|
import Text.Read hiding (lift)
|
||||||
|
|
||||||
|
getDaysCandles productString = do
|
||||||
|
oneDayAgo <- addUTCTime(-60*60*24) <$> getCurrentTime
|
||||||
|
let candles = CB.candles (CB.ProductId productString) (Just oneDayAgo) Nothing CB.Minute
|
||||||
|
CB.run CB.Production (candles CB.userAgent)
|
||||||
|
|
||||||
|
coinbaseProductLabel productString =
|
||||||
|
pollingLabelNew 60.0 $ Data.Text.pack . ((productString ++ ": ") ++) . show . CB.unPrice . CB.close . head <$> getDaysCandles (Data.Text.pack productString)
|
||||||
|
|
||||||
mkRGBA (r, g, b, a) = (r/256, g/256, b/256, a/256)
|
mkRGBA (r, g, b, a) = (r/256, g/256, b/256, a/256)
|
||||||
blue = mkRGBA (42, 99, 140, 256)
|
blue = mkRGBA (42, 99, 140, 256)
|
||||||
yellow1 = mkRGBA (242, 163, 54, 256)
|
yellow1 = mkRGBA (242, 163, 54, 256)
|
||||||
@ -153,6 +168,10 @@ main = do
|
|||||||
map (>>= buildContentsBox)
|
map (>>= buildContentsBox)
|
||||||
[ myClock
|
[ myClock
|
||||||
, sniTrayNew
|
, sniTrayNew
|
||||||
|
, coinbaseProductLabel "ICP-USD"
|
||||||
|
, coinbaseProductLabel "ICP-BTC"
|
||||||
|
, coinbaseProductLabel "BTC-USD"
|
||||||
|
, coinbaseProductLabel "ETH-USD"
|
||||||
, cpuGraph
|
, cpuGraph
|
||||||
, memoryGraph
|
, memoryGraph
|
||||||
, networkGraphNew netCfg Nothing
|
, networkGraphNew netCfg Nothing
|
||||||
|
Loading…
Reference in New Issue
Block a user