From d84b83cb96268961d3f5c7b13a08355467a1aca6 Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Sun, 27 Jan 2019 20:05:20 +0100 Subject: [PATCH] Add taffybar configuration --- taffybar/taffybar.css | 127 ++++++++++++++++++++++++++++++++++++++++++ taffybar/taffybar.hs | 98 ++++++++++++++++++++++++++++++++ 2 files changed, 225 insertions(+) create mode 100644 taffybar/taffybar.css create mode 100644 taffybar/taffybar.hs diff --git a/taffybar/taffybar.css b/taffybar/taffybar.css new file mode 100644 index 0000000..c0ecbd2 --- /dev/null +++ b/taffybar/taffybar.css @@ -0,0 +1,127 @@ +@define-color transparent rgba(0.0, 0.0, 0.0, 0.0); +@define-color white #FFFFFF; +@define-color black #000000; +@define-color taffy-blue #0c7cd5; + +@define-color active-window-color @white; +@define-color urgent-window-color @taffy-blue; +@define-color font-color @white; +@define-color menu-background-color @white; +@define-color menu-font-color @black; + +/* Top level styling */ + +.taffy-window * { + /* + This removes any existing styling from UI elements. Taffybar will not cohere + with your gtk theme. + */ + all: unset; + + font-family: "Noto Sans", sans-serif; + font-size: 10pt; + color: @font-color; +} + +.taffy-box { + border-radius: 10px; + background-color: rgba(0.0, 0.0, 0.0, 0.3); +} + +.inner-pad { + padding-bottom: 0px; + padding-top: 0px; + padding-left: 2px; + padding-right: 2px; +} + +.contents { + padding-bottom: 0px; + padding-top: 0px; + padding-right: 2px; + padding-left: 2px; + transition: background-color .5s; + border-radius: 5px; +} + +/* Workspaces styling */ + +.workspace-label { + padding-right: 3px; + padding-left: 2px; + font-size: 10pt; +} + +.active .contents { + background-color: rgba(0.0, 0.0, 0.0, 0.5); +} + +.visible .contents { + background-color: rgba(0.0, 0.0, 0.0, 0.2); +} + +.window-icon-container { + transition: opacity .5s, box-shadow .5s; + opacity: 1; +} + +/* This gives space for the box-shadow (they look like underlines) that follow. + This will actually affect all widgets, (not just the workspace icons), but + that is what we want since we want the icons to look the same. */ +.auto-size-image, .sni-tray { + padding-top: 3px; + padding-bottom: 3px; +} + +.window-icon-container.active { + box-shadow: inset 0 -3px @white; +} + +.window-icon-container.urgent { + box-shadow: inset 0 -3px @urgent-window-color; +} + +.window-icon-container.inactive .window-icon { + padding: 0px; +} + +.window-icon-container.minimized .window-icon { + opacity: .3; +} + +.window-icon { + opacity: 1; + transition: opacity .5s; +} + +/* Button styling */ + +button { + background-color: @transparent; + border-width: 0px; + border-radius: 0px; +} + +button:checked, button:hover .Contents:hover { + box-shadow: inset 0 -3px @taffy-blue; +} + +/* Menu styling */ + +/* The ".taffy-window" prefixed selectors are needed because if they aren't present, + the top level .Taffybar selector takes precedence */ +.taffy-window menuitem *, menuitem * { + color: @menu-font-color; +} + +.taffy-window menuitem, menuitem { + background-color: @menu-background-color; +} + +.taffy-window menuitem:hover, menuitem:hover { + background-color: @taffy-blue; +} + +.taffy-window menuitem:hover > label, menuitem:hover > label { + color: @white; +} diff --git a/taffybar/taffybar.hs b/taffybar/taffybar.hs new file mode 100644 index 0000000..7da5b67 --- /dev/null +++ b/taffybar/taffybar.hs @@ -0,0 +1,98 @@ +-- https://github.com/taffybar/taffybar/blob/master/taffybar.hs.example as of 2019-01-27 + +-- -*- mode:haskell -*- +{-# LANGUAGE OverloadedStrings #-} +module Main where + +import System.Taffybar +import System.Taffybar.Context hiding (startWidgets, endWidgets, widgetSpacing) +import System.Taffybar.Hooks +import System.Taffybar.Information.CPU +import System.Taffybar.Information.CPU2 +import System.Taffybar.Information.Memory +import System.Taffybar.SimpleConfig +import System.Taffybar.Widget +import System.Taffybar.Widget.Battery +import System.Taffybar.Widget.CommandRunner +import System.Taffybar.Widget.FreedesktopNotifications +import System.Taffybar.Widget.Generic.PollingGraph +import System.Taffybar.Widget.Generic.PollingLabel +import System.Taffybar.Widget.Text.NetworkMonitor +import System.Taffybar.Widget.Util +import System.Taffybar.Widget.Windows +import System.Taffybar.Widget.Workspaces + +import qualified GI.Gtk as Gtk +import qualified Data.Text as T + +transparent = (0.0, 0.0, 0.0, 0.0) +yellow1 = (0.9453125, 0.63671875, 0.2109375, 1.0) +yellow2 = (0.9921875, 0.796875, 0.32421875, 1.0) +green1 = (0, 1, 0, 1) +green2 = (1, 0, 1, 0.5) +taffyBlue = (0.129, 0.588, 0.953, 1) + +myGraphConfig = + defaultGraphConfig + { graphPadding = 0 + , graphBorderWidth = 0 + , graphWidth = 30 + , graphBackgroundColor = transparent + } + +memCfg = myGraphConfig + { graphDataColors = [taffyBlue] + , graphLabel = Just "mem" + } + +cpuCfg = myGraphConfig + { graphDataColors = [green1, green2] + , graphLabel = Just "cpu" + } + +memCallback :: IO [Double] +memCallback = do + mi <- parseMeminfo + return [memoryUsedRatio mi] + +cpuCallback = do + (_, systemLoad, totalLoad) <- cpuLoad + return [totalLoad, systemLoad] + +main = do + let myWorkspacesConfig = + defaultWorkspacesConfig + { minIcons = 1 + , widgetGap = 0 + , showWorkspaceFn = hideEmpty + } + workspaces = workspacesNew myWorkspacesConfig + cpu = pollingGraphNew cpuCfg 0.5 cpuCallback + mem = pollingGraphNew memCfg 1 memCallback + net = networkMonitorNew defaultNetFormat $ Just ["eth2", "wlan2"] + clock = textClockNew Nothing "%a %b %_d %T" 1 + layout = layoutNew defaultLayoutConfig + windows = windowsNew defaultWindowsConfig { getMenuLabel = truncatedGetMenuLabel 30 } + -- See https://github.com/taffybar/gtk-sni-tray#statusnotifierwatcher + -- for a better way to set up the sni tray + tray = sniTrayThatStartsWatcherEvenThoughThisIsABadWayToDoIt + bar = do + label <- Gtk.labelNew (Just "|" :: Maybe T.Text) + Gtk.widgetShowAll label + Gtk.toWidget label :: TaffyIO Gtk.Widget + myConfig = defaultSimpleTaffyConfig + { startWidgets = + (clock >>= buildContentsBox) : workspaces : map (>>= buildContentsBox) [ layout, bar, commandRunnerNew 1.0 "emacs-current-task" [] "…", bar, windows ] + , endWidgets = map (>>= buildContentsBox) + [ textBatteryNew "$percentage$% ($status$)" + , tray + , cpu + , mem + , net + , notifyAreaNew defaultNotificationConfig + ] + , barPosition = Top + , barHeight = 18 + , widgetSpacing = 0 + } + dyreTaffybar $ withBatteryRefresh $ withLogServer $ withToggleServer $ toTaffyConfig myConfig