forked from colonelpanic/dotfiles
[taffybar] Add crypto icons to crypto prices
This commit is contained in:
parent
6d7070b24d
commit
7168064982
@ -14,7 +14,6 @@ executable taffybar
|
|||||||
hs-source-dirs: .
|
hs-source-dirs: .
|
||||||
main-is: taffybar.hs
|
main-is: taffybar.hs
|
||||||
ghc-options: -threaded -rtsopts -with-rtsopts=-N
|
ghc-options: -threaded -rtsopts -with-rtsopts=-N
|
||||||
-- ghc-options: -threaded -g -rtsopts
|
|
||||||
ghc-prof-options: -fprof-auto
|
ghc-prof-options: -fprof-auto
|
||||||
build-depends: base
|
build-depends: base
|
||||||
, X11
|
, X11
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 0b30a778689902c54577306cd73ebb7ba79f8c6e
|
Subproject commit 00d8e0f88de31aed0f7a3baf2dc308e51763bcc6
|
@ -4,12 +4,14 @@
|
|||||||
@define-color taffy-blue #0c7cd5;
|
@define-color taffy-blue #0c7cd5;
|
||||||
@define-color taffy-navy rgb(25, 30, 55);
|
@define-color taffy-navy rgb(25, 30, 55);
|
||||||
@define-color taffy-red rgba(255, 65, 81, 1.0);
|
@define-color taffy-red rgba(255, 65, 81, 1.0);
|
||||||
|
@define-color taffy-teal #00695C;
|
||||||
|
|
||||||
@define-color active-window-color @white;
|
@define-color active-window-color @white;
|
||||||
@define-color urgent-window-color @taffy-blue;
|
@define-color urgent-window-color @taffy-blue;
|
||||||
@define-color font-color @white;
|
@define-color font-color @white;
|
||||||
@define-color menu-background-color @white;
|
@define-color menu-background-color @white;
|
||||||
@define-color menu-font-color @black;
|
@define-color menu-font-color @black;
|
||||||
|
@define-color bar-background @taffy-navy;
|
||||||
|
|
||||||
/* Top level styling */
|
/* Top level styling */
|
||||||
|
|
||||||
@ -18,32 +20,36 @@
|
|||||||
font-size: 10pt;
|
font-size: 10pt;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: @font-color;
|
color: @font-color;
|
||||||
border-radius: 4px;
|
|
||||||
text-shadow: 2px 2px @black;
|
text-shadow: 2px 2px @black;
|
||||||
}
|
}
|
||||||
|
|
||||||
.taffy-box {
|
.taffy-box {
|
||||||
border-color: @white;
|
border-color: @white;
|
||||||
border-style: solid;
|
border-style: solid;
|
||||||
background-color: @taffy-navy;
|
background-color: @bar-background;
|
||||||
padding: 3px;
|
padding: 3px;
|
||||||
margin: 4px;
|
margin: 4px;
|
||||||
}
|
border-radius: 4px;
|
||||||
|
|
||||||
.inner-pad {
|
|
||||||
padding: 0px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.contents {
|
.contents {
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
transition: background-color .5s;
|
transition: background-color .5s;
|
||||||
border-color: @white;
|
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
/* border-radius: 6px; */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Workspaces styling */
|
/* Workspaces styling */
|
||||||
|
|
||||||
|
.workspaces .inner-pad {
|
||||||
|
box-shadow: none;
|
||||||
|
border-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.workspaces .contents {
|
||||||
|
box-shadow: none;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
.workspace-label {
|
.workspace-label {
|
||||||
padding-right: 4px;
|
padding-right: 4px;
|
||||||
padding-left: 2px;
|
padding-left: 2px;
|
||||||
@ -56,9 +62,8 @@
|
|||||||
text-shadow: 2px 2px @black;
|
text-shadow: 2px 2px @black;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.contents .window-icon {
|
.contents .window-icon {
|
||||||
opacity: .5;
|
border-width: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.active .contents .window-icon {
|
.active .contents .window-icon {
|
||||||
@ -107,10 +112,6 @@
|
|||||||
.window-icon-container.urgent {
|
.window-icon-container.urgent {
|
||||||
}
|
}
|
||||||
|
|
||||||
.window-icon-container.inactive .window-icon {
|
|
||||||
padding: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.window-icon-container.minimized .window-icon {
|
.window-icon-container.minimized .window-icon {
|
||||||
opacity: .3;
|
opacity: .3;
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
{-# LANGUAGE TypeApplications #-}
|
||||||
|
{-# LANGUAGE DataKinds #-}
|
||||||
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
|
||||||
@ -17,9 +14,9 @@ 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 qualified Data.Text
|
||||||
|
import Data.Time
|
||||||
import qualified GI.Gtk as Gtk
|
import qualified GI.Gtk as Gtk
|
||||||
import qualified GI.Gtk.Objects.Overlay as Gtk
|
import qualified GI.Gtk.Objects.Overlay as Gtk
|
||||||
import Data.Time
|
|
||||||
import Network.HostName
|
import Network.HostName
|
||||||
import StatusNotifier.Tray
|
import StatusNotifier.Tray
|
||||||
import System.Directory
|
import System.Directory
|
||||||
@ -43,6 +40,7 @@ import System.Taffybar.Information.X11DesktopInfo
|
|||||||
import System.Taffybar.SimpleConfig
|
import System.Taffybar.SimpleConfig
|
||||||
import System.Taffybar.Util
|
import System.Taffybar.Util
|
||||||
import System.Taffybar.Widget
|
import System.Taffybar.Widget
|
||||||
|
import System.Taffybar.Widget.Crypto
|
||||||
import System.Taffybar.Widget.Generic.Icon
|
import System.Taffybar.Widget.Generic.Icon
|
||||||
import System.Taffybar.Widget.Generic.PollingGraph
|
import System.Taffybar.Widget.Generic.PollingGraph
|
||||||
import System.Taffybar.Widget.Generic.PollingLabel
|
import System.Taffybar.Widget.Generic.PollingLabel
|
||||||
@ -51,16 +49,11 @@ import System.Taffybar.Widget.Workspaces
|
|||||||
import Text.Printf
|
import Text.Printf
|
||||||
import Text.Read hiding (lift)
|
import Text.Read hiding (lift)
|
||||||
|
|
||||||
getDaysCandles productString = do
|
setClassAndBoundingBoxes :: MonadIO m => Data.Text.Text -> Gtk.Widget -> m Gtk.Widget
|
||||||
oneDayAgo <- addUTCTime(-60*60*24) <$> getCurrentTime
|
setClassAndBoundingBoxes klass = buildContentsBox >=> flip widgetSetClassGI klass
|
||||||
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 . show . CB.unPrice . CB.close . head <$>
|
|
||||||
getDaysCandles (Data.Text.pack productString)
|
|
||||||
|
|
||||||
|
|
||||||
|
deocrateWithSetClassAndBoxes :: MonadIO m => Data.Text.Text -> m Gtk.Widget -> m Gtk.Widget
|
||||||
|
deocrateWithSetClassAndBoxes klass builder = builder >>= setClassAndBoundingBoxes klass
|
||||||
|
|
||||||
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)
|
||||||
@ -143,80 +136,71 @@ main = do
|
|||||||
homeDirectory <- getHomeDirectory
|
homeDirectory <- getHomeDirectory
|
||||||
cssFilePath <-
|
cssFilePath <-
|
||||||
traverse (getUserConfigFile "taffybar") $ lookup hostName cssFileByHostname
|
traverse (getUserConfigFile "taffybar") $ lookup hostName cssFileByHostname
|
||||||
let cpuGraph = pollingGraphNew cpuCfg 5 cpuCallback
|
|
||||||
memoryGraph = pollingGraphNew memCfg 5 memCallback
|
let myCPU = deocrateWithSetClassAndBoxes "cpu" $ pollingGraphNew cpuCfg 5 cpuCallback
|
||||||
myIcons = scaledWindowIconPixbufGetter $
|
myMem = deocrateWithSetClassAndBoxes "mem" $ pollingGraphNew memCfg 5 memCallback
|
||||||
|
myNet = deocrateWithSetClassAndBoxes "net" $ networkGraphNew netCfg Nothing
|
||||||
|
myLayout = deocrateWithSetClassAndBoxes "layout" $ layoutNew defaultLayoutConfig
|
||||||
|
myWindows = deocrateWithSetClassAndBoxes "windows" $ windowsNew defaultWindowsConfig
|
||||||
|
myWorkspaces =
|
||||||
|
flip widgetSetClassGI "workspaces" =<<
|
||||||
|
workspacesNew defaultWorkspacesConfig
|
||||||
|
{ minIcons = 1
|
||||||
|
, getWindowIconPixbuf =
|
||||||
|
scaledWindowIconPixbufGetter $
|
||||||
getWindowIconPixbufFromChrome <|||>
|
getWindowIconPixbufFromChrome <|||>
|
||||||
unscaledDefaultGetWindowIconPixbuf <|||>
|
unscaledDefaultGetWindowIconPixbuf <|||>
|
||||||
(\size _ -> lift $ loadPixbufByName size "application-default-icon")
|
(\size _ -> lift $ loadPixbufByName size "application-default-icon")
|
||||||
layout = layoutNew defaultLayoutConfig
|
|
||||||
windows = windowsNew defaultWindowsConfig
|
|
||||||
|
|
||||||
myWorkspacesConfig =
|
|
||||||
defaultWorkspacesConfig
|
|
||||||
{ underlineHeight = 3
|
|
||||||
, underlinePadding = 2
|
|
||||||
, minIcons = 1
|
|
||||||
, getWindowIconPixbuf = myIcons
|
|
||||||
, widgetGap = 0
|
, widgetGap = 0
|
||||||
, showWorkspaceFn = hideEmpty
|
, showWorkspaceFn = hideEmpty
|
||||||
, updateRateLimitMicroseconds = 100000
|
, updateRateLimitMicroseconds = 100000
|
||||||
, labelSetter = workspaceNamesLabelSetter
|
, labelSetter = workspaceNamesLabelSetter
|
||||||
, widgetBuilder = buildLabelOverlayController
|
, widgetBuilder = buildLabelOverlayController
|
||||||
}
|
}
|
||||||
workspaces = workspacesNew myWorkspacesConfig
|
myClock = deocrateWithSetClassAndBoxes "clock" $
|
||||||
myClock =
|
|
||||||
textClockNewWith
|
textClockNewWith
|
||||||
defaultClockConfig
|
defaultClockConfig
|
||||||
{ clockUpdateStrategy = RoundedTargetInterval 60 0.0
|
{ clockUpdateStrategy = RoundedTargetInterval 60 0.0
|
||||||
, clockFormatString = "%a %b %_d %I:%M %p"
|
, clockFormatString = "%a %b %_d, %I:%M %p"
|
||||||
}
|
}
|
||||||
fullEndWidgets =
|
myICP = deocrateWithSetClassAndBoxes "icp" $ cryptoPriceLabelWithIcon @"ICP-USD"
|
||||||
map (>>= buildContentsBox)
|
myBTC = deocrateWithSetClassAndBoxes "btc" $ cryptoPriceLabelWithIcon @"BTC-USD"
|
||||||
[ myClock
|
myETH = deocrateWithSetClassAndBoxes "eth" $ cryptoPriceLabelWithIcon @"ETH-USD"
|
||||||
, sniTrayNewFromParams defaultTrayParams { trayLeftClickAction = PopupMenu
|
myTray = deocrateWithSetClassAndBoxes "tray" $
|
||||||
|
sniTrayNewFromParams defaultTrayParams { trayLeftClickAction = PopupMenu
|
||||||
, trayRightClickAction = Activate
|
, trayRightClickAction = Activate
|
||||||
}
|
}
|
||||||
, coinbaseProductLabel "ICP-USD"
|
myMpris = deocrateWithSetClassAndBoxes "mpris" mpris2New
|
||||||
, coinbaseProductLabel "ICP-BTC"
|
myBatteryIcon = deocrateWithSetClassAndBoxes "battery-icon" batteryIconNew
|
||||||
, coinbaseProductLabel "BTC-USD"
|
myBatteryText =
|
||||||
, coinbaseProductLabel "ETH-USD"
|
deocrateWithSetClassAndBoxes "battery-text" $ textBatteryNew "$percentage$%"
|
||||||
, cpuGraph
|
fullEndWidgets =
|
||||||
, memoryGraph
|
[ myTray
|
||||||
, networkGraphNew netCfg Nothing
|
, myICP
|
||||||
-- , networkMonitorNew defaultNetFormat Nothing >>= setMinWidth 200
|
, myBTC
|
||||||
-- , fsMonitorNew 60 ["/dev/sdd2"]
|
, myETH
|
||||||
, mpris2New
|
, myCPU
|
||||||
|
, myMem
|
||||||
|
, myNet
|
||||||
|
, myMpris
|
||||||
]
|
]
|
||||||
shortLaptopEndWidgets =
|
shortLaptopEndWidgets =
|
||||||
map (>>= buildContentsBox)
|
[ myBatteryIcon
|
||||||
[ batteryIconNew
|
, myBatteryText
|
||||||
, textBatteryNew "$percentage$%"
|
|
||||||
, myClock
|
, myClock
|
||||||
, sniTrayNew
|
, myTray
|
||||||
, coinbaseProductLabel "ICP-USD"
|
, myICP
|
||||||
, mpris2New
|
, myMpris
|
||||||
]
|
|
||||||
longLaptopEndWidgets =
|
|
||||||
map (>>= buildContentsBox)
|
|
||||||
[ batteryIconNew
|
|
||||||
, textBatteryNew "$percentage$%"
|
|
||||||
, textClockNewWith defaultClockConfig
|
|
||||||
, sniTrayNew
|
|
||||||
, cpuGraph
|
|
||||||
, memoryGraph
|
|
||||||
, networkGraphNew netCfg Nothing
|
|
||||||
, mpris2New
|
|
||||||
]
|
]
|
||||||
baseConfig =
|
baseConfig =
|
||||||
defaultSimpleTaffyConfig
|
defaultSimpleTaffyConfig
|
||||||
{ startWidgets =
|
{ startWidgets = [myWorkspaces, myLayout, myWindows]
|
||||||
workspaces : map (>>= buildContentsBox) [layout, windows]
|
|
||||||
, endWidgets = fullEndWidgets
|
, endWidgets = fullEndWidgets
|
||||||
, barPosition = Top
|
, barPosition = Top
|
||||||
, barPadding = 0
|
, barPadding = 0
|
||||||
, barHeight = 50
|
, barHeight = 50
|
||||||
, cssPath = cssFilePath
|
, cssPath = cssFilePath
|
||||||
|
, startupHook = void $ setCMCAPIKey "f9e66366-9d42-4c6e-8d40-4194a0aaa329"
|
||||||
}
|
}
|
||||||
selectedConfig =
|
selectedConfig =
|
||||||
fromMaybe baseConfig $ lookup hostName
|
fromMaybe baseConfig $ lookup hostName
|
||||||
@ -234,7 +218,7 @@ main = do
|
|||||||
)
|
)
|
||||||
]
|
]
|
||||||
simpleTaffyConfig = selectedConfig
|
simpleTaffyConfig = selectedConfig
|
||||||
{ centerWidgets = []
|
{ centerWidgets = [ myClock ]
|
||||||
-- , endWidgets = []
|
-- , endWidgets = []
|
||||||
-- , startWidgets = []
|
-- , startWidgets = []
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user