From 3b7570302868b7e09425676c4a0df07a176b3aed Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Thu, 26 Oct 2017 17:59:57 -0700 Subject: [PATCH] [taffybar] Move some size configuration to css file --- dotfiles/config/taffybar/taffybar | 2 +- dotfiles/config/taffybar/taffybar.css | 54 +++++++++++++++------- dotfiles/config/taffybar/taffybar.hs | 65 +++++++++++++++------------ 3 files changed, 74 insertions(+), 47 deletions(-) diff --git a/dotfiles/config/taffybar/taffybar b/dotfiles/config/taffybar/taffybar index 5a01a6c7..103897e8 160000 --- a/dotfiles/config/taffybar/taffybar +++ b/dotfiles/config/taffybar/taffybar @@ -1 +1 @@ -Subproject commit 5a01a6c7df328da4b012dd054b5a8314f1594640 +Subproject commit 103897e89fb76147b04d7c8d9bce321ea8882d79 diff --git a/dotfiles/config/taffybar/taffybar.css b/dotfiles/config/taffybar/taffybar.css index 8a0f4f1b..6e70409c 100644 --- a/dotfiles/config/taffybar/taffybar.css +++ b/dotfiles/config/taffybar/taffybar.css @@ -1,31 +1,50 @@ @define-color taffybar_bg_color #000000; @define-color taffybar_bg_tone #212121; -@define-color taffybar_highlight_color #ffeb3b; - -.Active.Underline { - background-color: @taffybar_highlight_color; - border-radius: 1px; -} +@define-color taffybar_active_window_color rgba(255, 255, 255, .5); .IconContainer { border-radius: 5px; } -.IconContainer.Active { - background-color: @taffybar_highlight_color; +.IconImage { + padding: 2px; } -.IconContainer.Minimized { - opacity: .3; +.IconContainer { + transition: background-color .5s, opacity.5s; + opacity: 1; + background-color: @taffybar-bg-tone; } .IconContainer.Urgent { - background-color: #ffffff; + transition: background-color .5s; + background-color: #ff0000; } -.Active.Container, .Visible.Container { - background-color: @taffybar_bg_tone; +.IconContainer.Active { + transition: background-color .5s; + background-color: @taffybar_active_window_color; +} + +.IconContainer.Minimized .IconImage { + transition: opacity .5s; + opacity: .3; +} + +.Contents { border-radius: 5px; + padding: 3px; +} + +.Contents.Cpu { +} + +.Active .Contents, .Visible .Contents { + background-color: @taffybar_bg_tone; +} + +.InnerPad { + padding: 4px; } .Taffybar { @@ -35,12 +54,13 @@ .Taffybar * { font-family: "Fira Sans", sans-serif; - font-size: 12pt; + font-size: 10pt; } -.Taffybar .Container * { - font-family: 'Source Code Pro'; - font-size: 16pt; +.WorkspaceLabel { + padding-right: 3px; + padding-left: 2px; + font-size: 12pt; } #WindowSwitcher { diff --git a/dotfiles/config/taffybar/taffybar.hs b/dotfiles/config/taffybar/taffybar.hs index d2955552..bc2476b3 100644 --- a/dotfiles/config/taffybar/taffybar.hs +++ b/dotfiles/config/taffybar/taffybar.hs @@ -41,9 +41,21 @@ instance WorkspaceWidgetController ConstantIconController where updateWidget cic _ = return cic getWidget = Gtk.toWidget . cicImage +instance WorkspaceWidgetController Gtk.Widget where + updateWidget w _ = return w + getWidget w = w + +makeContents waction klass = do + widget <- waction + widgetSetClass widget "Contents" + widgetSetClass widget klass + b <- buildPadBox widget + Gtk.widgetShowAll b + return $ Gtk.toWidget b + myGraphConfig = defaultGraphConfig - { graphPadding = 5 + { graphPadding = 0 , graphBorderWidth = 0 , graphWidth = 75 } @@ -52,13 +64,9 @@ memCfg = myGraphConfig {graphDataColors = [(0.129, 0.588, 0.953, 1)], graphLabel = Just "mem"} -memCallback :: Gtk.Widget -> IO [Double] -memCallback widget = do +memCallback :: IO [Double] +memCallback = do mi <- parseMeminfo - let tooltip = printf "%s/%s" (show $ memoryUsed mi) (show $ memoryTotal mi) :: String - Gtk.postGUIAsync $ do - _ <- Gtk.widgetSetTooltipText widget (Just tooltip) - return () return [memoryUsedRatio mi] getFullWorkspaceNames :: X11Property [(WorkspaceIdx, String)] @@ -69,14 +77,14 @@ workspaceNamesLabelSetter workspace = do fullNames <- liftX11Def [] getFullWorkspaceNames return $ fromMaybe "" $ lookup (workspaceIdx workspace) fullNames -mem :: IO Gtk.Widget -mem = do - ebox <- Gtk.eventBoxNew - btn <- pollingGraphNew memCfg 1 $ memCallback $ Gtk.toWidget ebox - Gtk.containerAdd ebox btn - _ <- Gtk.on ebox Gtk.buttonPressEvent systemEvents - Gtk.widgetShowAll ebox - return $ Gtk.toWidget ebox +-- mem :: IO Gtk.Widget +-- mem = do +-- ebox <- Gtk.eventBoxNew +-- btn <- pollingGraphNew memCfg 1 $ memCallback $ Gtk.toWidget ebox +-- Gtk.containerAdd ebox btn +-- _ <- Gtk.on ebox Gtk.buttonPressEvent systemEvents +-- Gtk.widgetShowAll ebox +-- return $ Gtk.toWidget ebox systemEvents :: Gtk.EventM Gtk.EButton Bool systemEvents = return True @@ -85,6 +93,9 @@ cpuCallback = do (_, systemLoad, totalLoad) <- cpuLoad return [totalLoad, systemLoad] +containerAddReturn c w = + Gtk.containerAdd c w >> Gtk.widgetShowAll c >> (return $ Gtk.toWidget c) + underlineWidget cfg buildWidget name = do w <- buildWidget t <- T.tableNew 2 1 False @@ -179,6 +190,7 @@ main = do clock = textClockNew Nothing "%a %b %_d %r" 1 mpris = mpris2New cpu = pollingGraphNew cpuCfg 0.5 cpuCallback + mem = pollingGraphNew memCfg 1 memCallback myHUDConfig = defaultWorkspaceHUDConfig { underlineHeight = 3 @@ -186,7 +198,7 @@ main = do , minWSWidgetSize = Nothing , minIcons = 1 , getIconInfo = myGetIconInfo - , windowIconSize = 28 + , windowIconSize = 30 , widgetGap = 0 -- , widgetBuilder = -- buildButtonController $ @@ -198,12 +210,8 @@ main = do -- ] , showWorkspaceFn = hideEmpty , updateRateLimitMicroseconds = 100000 - , updateIconsOnTitleChange = True , updateOnWMIconChange = True , debugMode = False - , redrawIconsOnStateChange = True - , innerPadding = 5 - , outerPadding = 5 , labelSetter = workspaceNamesLabelSetter } netMonitor = netMonitorMultiNew 1.5 interfaceNames @@ -221,18 +229,17 @@ main = do { startWidgets = [hud, los, wnd] , endWidgets = [ batteryBarNew defaultBatteryConfig 1.0 - , clock - , systrayNew - , mem - , cpu - , netMonitor - , mpris + , makeContents clock "Cpu" + -- , systrayNew + , makeContents cpu "Cpu" + , makeContents mem "Cpu" + , makeContents netMonitor "Cpu" + , makeContents (join $ containerAddReturn <$> Gtk.eventBoxNew <*> mpris) "Cpu" ] , barPosition = Top , barPadding = 10 - , barHeight = (underlineHeight myHUDConfig + windowIconSize myHUDConfig) + - (2 * (innerPadding myHUDConfig + outerPadding myHUDConfig)) - , widgetSpacing = 5 + , barHeight = (underlineHeight myHUDConfig + windowIconSize myHUDConfig) + 15 + , widgetSpacing = 0 } withToggleSupport taffyConfig