style(taffybar): align combined labels and keep clock centered
This commit is contained in:
@@ -30,6 +30,12 @@
|
|||||||
padding-right: 11px;
|
padding-right: 11px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Keep icon+label "combined" widgets left-aligned, including multiline labels. */
|
||||||
|
.icon-label > .label {
|
||||||
|
-GtkLabel-xalign: 0;
|
||||||
|
-GtkLabel-justify: left;
|
||||||
|
}
|
||||||
|
|
||||||
/* Compact two-line RAM/SWAP widget: reduce icon padding a bit. */
|
/* Compact two-line RAM/SWAP widget: reduce icon padding a bit. */
|
||||||
.ram-swap .icon-label > .icon {
|
.ram-swap .icon-label > .icon {
|
||||||
/* Different glyphs have different visual widths; fix the icon column width
|
/* Different glyphs have different visual widths; fix the icon column width
|
||||||
@@ -301,6 +307,12 @@
|
|||||||
letter-spacing: 0.2px;
|
letter-spacing: 0.2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Clock stays centered even though combined widgets are left-aligned. */
|
||||||
|
.clock label {
|
||||||
|
-GtkLabel-xalign: 0.5;
|
||||||
|
-GtkLabel-justify: center;
|
||||||
|
}
|
||||||
|
|
||||||
.wakeup-debug label {
|
.wakeup-debug label {
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import Control.Monad (when)
|
|||||||
import Control.Monad.IO.Class (MonadIO, liftIO)
|
import Control.Monad.IO.Class (MonadIO, liftIO)
|
||||||
import Control.Monad.Trans.Reader (asks)
|
import Control.Monad.Trans.Reader (asks)
|
||||||
import Data.Char (toLower)
|
import Data.Char (toLower)
|
||||||
|
import Data.GI.Base (castTo)
|
||||||
import Data.IORef (IORef, modifyIORef', newIORef, readIORef)
|
import Data.IORef (IORef, modifyIORef', newIORef, readIORef)
|
||||||
import Data.Int (Int32)
|
import Data.Int (Int32)
|
||||||
import Data.List (nub, sortOn, stripPrefix)
|
import Data.List (nub, sortOn, stripPrefix)
|
||||||
@@ -75,6 +76,21 @@ decorateWithClassAndBoxM :: (MonadIO m) => Text -> m Gtk.Widget -> m Gtk.Widget
|
|||||||
decorateWithClassAndBoxM klass builder =
|
decorateWithClassAndBoxM klass builder =
|
||||||
builder >>= decorateWithClassAndBox klass
|
builder >>= decorateWithClassAndBox klass
|
||||||
|
|
||||||
|
setLabelAlignmentRecursively :: Float -> Gtk.Justification -> Gtk.Widget -> IO ()
|
||||||
|
setLabelAlignmentRecursively xalign justify widget = do
|
||||||
|
maybeLabel <- castTo Gtk.Label widget
|
||||||
|
case maybeLabel of
|
||||||
|
Just label -> do
|
||||||
|
Gtk.labelSetXalign label xalign
|
||||||
|
Gtk.labelSetJustify label justify
|
||||||
|
Nothing -> pure ()
|
||||||
|
|
||||||
|
maybeContainer <- castTo Gtk.Container widget
|
||||||
|
case maybeContainer of
|
||||||
|
Just container ->
|
||||||
|
Gtk.containerGetChildren container >>= mapM_ (setLabelAlignmentRecursively xalign justify)
|
||||||
|
Nothing -> pure ()
|
||||||
|
|
||||||
-- ** X11 Workspaces
|
-- ** X11 Workspaces
|
||||||
|
|
||||||
x11FullWorkspaceNames :: X11Property [(WorkspaceId, String)]
|
x11FullWorkspaceNames :: X11Property [(WorkspaceId, String)]
|
||||||
@@ -265,15 +281,15 @@ workspacesWidget = Workspaces.workspacesNew cfg
|
|||||||
}
|
}
|
||||||
|
|
||||||
clockWidget :: TaffyIO Gtk.Widget
|
clockWidget :: TaffyIO Gtk.Widget
|
||||||
clockWidget =
|
clockWidget = do
|
||||||
decorateWithClassAndBoxM
|
clock <-
|
||||||
"clock"
|
textClockNewWith
|
||||||
( textClockNewWith
|
|
||||||
defaultClockConfig
|
defaultClockConfig
|
||||||
{ clockUpdateStrategy = RoundedTargetInterval 60 0.0,
|
{ clockUpdateStrategy = RoundedTargetInterval 60 0.0,
|
||||||
clockFormatString = "%a %b %_d\n%I:%M %p"
|
clockFormatString = "%a %b %_d\n%I:%M %p"
|
||||||
}
|
}
|
||||||
)
|
liftIO $ setLabelAlignmentRecursively 0.5 Gtk.JustificationCenter clock
|
||||||
|
decorateWithClassAndBox "clock" clock
|
||||||
|
|
||||||
singleLineMprisLabel :: Text -> Text
|
singleLineMprisLabel :: Text -> Text
|
||||||
singleLineMprisLabel =
|
singleLineMprisLabel =
|
||||||
|
|||||||
Reference in New Issue
Block a user