[taffybar] Move some size configuration to css file

This commit is contained in:
Ivan Malison 2017-10-26 17:59:57 -07:00
parent c1432a83bf
commit 3b75703028
No known key found for this signature in database
GPG Key ID: 62530EFBE99DC2F8
3 changed files with 74 additions and 47 deletions

@ -1 +1 @@
Subproject commit 5a01a6c7df328da4b012dd054b5a8314f1594640 Subproject commit 103897e89fb76147b04d7c8d9bce321ea8882d79

View File

@ -1,31 +1,50 @@
@define-color taffybar_bg_color #000000; @define-color taffybar_bg_color #000000;
@define-color taffybar_bg_tone #212121; @define-color taffybar_bg_tone #212121;
@define-color taffybar_highlight_color #ffeb3b; @define-color taffybar_active_window_color rgba(255, 255, 255, .5);
.Active.Underline {
background-color: @taffybar_highlight_color;
border-radius: 1px;
}
.IconContainer { .IconContainer {
border-radius: 5px; border-radius: 5px;
} }
.IconContainer.Active { .IconImage {
background-color: @taffybar_highlight_color; padding: 2px;
} }
.IconContainer.Minimized { .IconContainer {
opacity: .3; transition: background-color .5s, opacity.5s;
opacity: 1;
background-color: @taffybar-bg-tone;
} }
.IconContainer.Urgent { .IconContainer.Urgent {
background-color: #ffffff; transition: background-color .5s;
background-color: #ff0000;
} }
.Active.Container, .Visible.Container { .IconContainer.Active {
background-color: @taffybar_bg_tone; transition: background-color .5s;
background-color: @taffybar_active_window_color;
}
.IconContainer.Minimized .IconImage {
transition: opacity .5s;
opacity: .3;
}
.Contents {
border-radius: 5px; border-radius: 5px;
padding: 3px;
}
.Contents.Cpu {
}
.Active .Contents, .Visible .Contents {
background-color: @taffybar_bg_tone;
}
.InnerPad {
padding: 4px;
} }
.Taffybar { .Taffybar {
@ -35,12 +54,13 @@
.Taffybar * { .Taffybar * {
font-family: "Fira Sans", sans-serif; font-family: "Fira Sans", sans-serif;
font-size: 12pt; font-size: 10pt;
} }
.Taffybar .Container * { .WorkspaceLabel {
font-family: 'Source Code Pro'; padding-right: 3px;
font-size: 16pt; padding-left: 2px;
font-size: 12pt;
} }
#WindowSwitcher { #WindowSwitcher {

View File

@ -41,9 +41,21 @@ instance WorkspaceWidgetController ConstantIconController where
updateWidget cic _ = return cic updateWidget cic _ = return cic
getWidget = Gtk.toWidget . cicImage 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 = myGraphConfig =
defaultGraphConfig defaultGraphConfig
{ graphPadding = 5 { graphPadding = 0
, graphBorderWidth = 0 , graphBorderWidth = 0
, graphWidth = 75 , graphWidth = 75
} }
@ -52,13 +64,9 @@ memCfg =
myGraphConfig myGraphConfig
{graphDataColors = [(0.129, 0.588, 0.953, 1)], graphLabel = Just "mem"} {graphDataColors = [(0.129, 0.588, 0.953, 1)], graphLabel = Just "mem"}
memCallback :: Gtk.Widget -> IO [Double] memCallback :: IO [Double]
memCallback widget = do memCallback = do
mi <- parseMeminfo 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] return [memoryUsedRatio mi]
getFullWorkspaceNames :: X11Property [(WorkspaceIdx, String)] getFullWorkspaceNames :: X11Property [(WorkspaceIdx, String)]
@ -69,14 +77,14 @@ workspaceNamesLabelSetter workspace = do
fullNames <- liftX11Def [] getFullWorkspaceNames fullNames <- liftX11Def [] getFullWorkspaceNames
return $ fromMaybe "" $ lookup (workspaceIdx workspace) fullNames return $ fromMaybe "" $ lookup (workspaceIdx workspace) fullNames
mem :: IO Gtk.Widget -- mem :: IO Gtk.Widget
mem = do -- mem = do
ebox <- Gtk.eventBoxNew -- ebox <- Gtk.eventBoxNew
btn <- pollingGraphNew memCfg 1 $ memCallback $ Gtk.toWidget ebox -- btn <- pollingGraphNew memCfg 1 $ memCallback $ Gtk.toWidget ebox
Gtk.containerAdd ebox btn -- Gtk.containerAdd ebox btn
_ <- Gtk.on ebox Gtk.buttonPressEvent systemEvents -- _ <- Gtk.on ebox Gtk.buttonPressEvent systemEvents
Gtk.widgetShowAll ebox -- Gtk.widgetShowAll ebox
return $ Gtk.toWidget ebox -- return $ Gtk.toWidget ebox
systemEvents :: Gtk.EventM Gtk.EButton Bool systemEvents :: Gtk.EventM Gtk.EButton Bool
systemEvents = return True systemEvents = return True
@ -85,6 +93,9 @@ cpuCallback = do
(_, systemLoad, totalLoad) <- cpuLoad (_, systemLoad, totalLoad) <- cpuLoad
return [totalLoad, systemLoad] return [totalLoad, systemLoad]
containerAddReturn c w =
Gtk.containerAdd c w >> Gtk.widgetShowAll c >> (return $ Gtk.toWidget c)
underlineWidget cfg buildWidget name = do underlineWidget cfg buildWidget name = do
w <- buildWidget w <- buildWidget
t <- T.tableNew 2 1 False t <- T.tableNew 2 1 False
@ -179,6 +190,7 @@ main = do
clock = textClockNew Nothing "%a %b %_d %r" 1 clock = textClockNew Nothing "%a %b %_d %r" 1
mpris = mpris2New mpris = mpris2New
cpu = pollingGraphNew cpuCfg 0.5 cpuCallback cpu = pollingGraphNew cpuCfg 0.5 cpuCallback
mem = pollingGraphNew memCfg 1 memCallback
myHUDConfig = myHUDConfig =
defaultWorkspaceHUDConfig defaultWorkspaceHUDConfig
{ underlineHeight = 3 { underlineHeight = 3
@ -186,7 +198,7 @@ main = do
, minWSWidgetSize = Nothing , minWSWidgetSize = Nothing
, minIcons = 1 , minIcons = 1
, getIconInfo = myGetIconInfo , getIconInfo = myGetIconInfo
, windowIconSize = 28 , windowIconSize = 30
, widgetGap = 0 , widgetGap = 0
-- , widgetBuilder = -- , widgetBuilder =
-- buildButtonController $ -- buildButtonController $
@ -198,12 +210,8 @@ main = do
-- ] -- ]
, showWorkspaceFn = hideEmpty , showWorkspaceFn = hideEmpty
, updateRateLimitMicroseconds = 100000 , updateRateLimitMicroseconds = 100000
, updateIconsOnTitleChange = True
, updateOnWMIconChange = True , updateOnWMIconChange = True
, debugMode = False , debugMode = False
, redrawIconsOnStateChange = True
, innerPadding = 5
, outerPadding = 5
, labelSetter = workspaceNamesLabelSetter , labelSetter = workspaceNamesLabelSetter
} }
netMonitor = netMonitorMultiNew 1.5 interfaceNames netMonitor = netMonitorMultiNew 1.5 interfaceNames
@ -221,18 +229,17 @@ main = do
{ startWidgets = [hud, los, wnd] { startWidgets = [hud, los, wnd]
, endWidgets = , endWidgets =
[ batteryBarNew defaultBatteryConfig 1.0 [ batteryBarNew defaultBatteryConfig 1.0
, clock , makeContents clock "Cpu"
, systrayNew -- , systrayNew
, mem , makeContents cpu "Cpu"
, cpu , makeContents mem "Cpu"
, netMonitor , makeContents netMonitor "Cpu"
, mpris , makeContents (join $ containerAddReturn <$> Gtk.eventBoxNew <*> mpris) "Cpu"
] ]
, barPosition = Top , barPosition = Top
, barPadding = 10 , barPadding = 10
, barHeight = (underlineHeight myHUDConfig + windowIconSize myHUDConfig) + , barHeight = (underlineHeight myHUDConfig + windowIconSize myHUDConfig) + 15
(2 * (innerPadding myHUDConfig + outerPadding myHUDConfig)) , widgetSpacing = 0
, widgetSpacing = 5
} }
withToggleSupport taffyConfig withToggleSupport taffyConfig