From 0b4c39ed810f11bf171d7c8d80eabd04ee6d3316 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Thu, 3 May 2018 22:42:39 -0700 Subject: [PATCH] [taffybar] New styling, use new network monitor widgets --- dotfiles/config/taffybar/taffybar | 2 +- dotfiles/config/taffybar/taffybar.css | 25 +++++++++--- dotfiles/config/taffybar/taffybar.hs | 55 ++++++++++++++++++++------- 3 files changed, 61 insertions(+), 21 deletions(-) diff --git a/dotfiles/config/taffybar/taffybar b/dotfiles/config/taffybar/taffybar index 25f5c507..ca3aa9e5 160000 --- a/dotfiles/config/taffybar/taffybar +++ b/dotfiles/config/taffybar/taffybar @@ -1 +1 @@ -Subproject commit 25f5c507598fdcb1b1c490ac9ec993e443422d9d +Subproject commit ca3aa9e528e92a1eb248f8632b4e5db0b640b947 diff --git a/dotfiles/config/taffybar/taffybar.css b/dotfiles/config/taffybar/taffybar.css index 0484bf1b..483a21cb 100644 --- a/dotfiles/config/taffybar/taffybar.css +++ b/dotfiles/config/taffybar/taffybar.css @@ -9,7 +9,7 @@ transition: border-color .5s; border-radius: 5px; border-style: solid; - border-width: 1; + border-width: 1px; border-color: rgba(1.0, 1.0, 1.0, 0.0); } @@ -31,7 +31,7 @@ transition: border-color .5s; border-radius: 0px; border-bottom: solid; - border-width: 1; + border-width: 1px; border-color: rgba(1.0, 1.0, 1.0, 0.0); } @@ -77,7 +77,7 @@ .TaffyBox { border-bottom: solid; - border-width: 1; + border-width: 1px; border-color: #FFFFFF; background-color: rgba(0.0, 0.0, 0.0, 0.3); } @@ -88,7 +88,20 @@ color: @font-color; } -.menubar * { - background-color: rgba(1.0, 1.0, 1.0, 0.0); - color: #000000; +.Menu * { + color: #FFFFFF; + background-color: rgba(1.0, 1.0, 1.0, 1.0); +} + +.OuterPad * { + background-color: rgba(1.0, 0.0, 0.0, 0.0); +} + +.OuterPad:focus { + background-color: rgba(0.0, 0.0, 0.0, 0.3); + box-shadow: inset 0 -3px #0c7cd5; +} + +.OuterPad *:hover { + box-shadow: inset 0 -3px #0c7cd5; } diff --git a/dotfiles/config/taffybar/taffybar.hs b/dotfiles/config/taffybar/taffybar.hs index b5cfc636..48b1d721 100644 --- a/dotfiles/config/taffybar/taffybar.hs +++ b/dotfiles/config/taffybar/taffybar.hs @@ -33,8 +33,10 @@ import System.Log.Logger import System.Process import System.Taffybar import System.Taffybar.Auth +import System.Taffybar.Compat.GtkLibs import System.Taffybar.DBus import System.Taffybar.DBus.Toggle +import System.Taffybar.Hooks import System.Taffybar.IconImages import System.Taffybar.Information.CPU import System.Taffybar.Information.EWMHDesktopInfo @@ -48,6 +50,15 @@ import Text.Printf import Text.Read hiding (lift) import Unsafe.Coerce +buildPadBoxNoShrink orig = liftIO $ do + widget <- buildPadBox orig + -- toGIWidget widget >>= widgetPreventShrink + return widget + +setMinWidth width widget = liftIO $ do + Gtk.widgetSetSizeRequest widget width (-1) + return widget + makeContents waction klass = do widget <- waction liftIO $ do @@ -57,11 +68,25 @@ makeContents waction klass = do Gtk.widgetShowAll b return $ Gtk.toWidget b +mkRGBA (r, g, b, a) = (r/256, g/256, b/256, a/256) +blue = mkRGBA (42, 99, 140, 256) +yellow1 = mkRGBA (242, 163, 54, 256) +yellow2 = mkRGBA (254, 204, 83, 256) +yellow3 = mkRGBA (227, 134, 18, 256) +red = mkRGBA (210, 77, 37, 256) + myGraphConfig = defaultGraphConfig { graphPadding = 0 , graphBorderWidth = 0 , graphWidth = 75 + , graphBackgroundColor = (1.0, 1.0, 1.0, 0.0) + } + +netCfg = + myGraphConfig + { graphDataColors = [yellow1, yellow2] + , graphLabel = Just "net" } memCfg = @@ -175,12 +200,15 @@ main = do cpuCfg = myGraphConfig { graphDataColors = [(0, 1, 0, 1), (1, 0, 1, 0.5)] + , graphBackgroundColor = (1.0, 1.0, 1.0, 0.0) , graphLabel = Just "cpu" } clock = textClockNew Nothing "%a %b %_d %r" 1 mpris = mpris2New cpu = pollingGraphNew cpuCfg 0.5 cpuCallback mem = pollingGraphNew memCfg 1 memCallback + battery = batteryBarNewWithFormat defaultBatteryConfig + "$percentage$% ($time$) - $status$" 1.0 myWorkspacesConfig = defaultWorkspacesConfig { underlineHeight = 3 @@ -194,24 +222,23 @@ main = do , updateRateLimitMicroseconds = 100000 , labelSetter = workspaceNamesLabelSetter } - netMonitor = netMonitorMultiNew 1.5 interfaceNames baseConfig = defaultSimpleTaffyConfig { startWidgets = [ workspaces - , makeContents los "Layout" - , makeContents wnd "Windows" + , los >>= buildPadBox + , wnd >>= buildPadBox ] - , endWidgets = - [ batteryBarNewWithFormat defaultBatteryConfig "$percentage$% ($time$) - $status$" 1.0 - , makeContents sniTrayNew "Cpu" - , makeContents clock "Cpu" - , github >>= buildPadBox - , makeContents cpu "Cpu" - , makeContents mem "Cpu" - , makeContents netMonitor "Cpu" - -- TODO: make support all devices - , makeContents (fsMonitorNew 60 ["/dev/sdd2"]) "Cpu" - , mpris >>= buildPadBox + , endWidgets = map (>>= buildPadBoxNoShrink) + [ clock >>= setMinWidth 200 + , sniTrayNew + , github + , battery + , cpu + , mem + , netMonitorGraphNew netCfg Nothing + , networkMonitorNew defaultNetFormat Nothing >>= setMinWidth 200 + , fsMonitorNew 60 ["/dev/sdd2"] + , mpris ] , barPosition = Top , barPadding = 0