[taffybar] Simplify taffybar.hs

This commit is contained in:
Ivan Malison 2018-05-21 12:44:12 -07:00
parent 1f1e0c2990
commit 0d648056df
No known key found for this signature in database
GPG Key ID: 62530EFBE99DC2F8
4 changed files with 113 additions and 124 deletions

View File

@ -27,11 +27,12 @@ extra-deps:
- gi-gdkx11-3.0.2 - gi-gdkx11-3.0.2
- gi-gio-2.0.16 - gi-gio-2.0.16
- gi-gtk-3.0.21 - gi-gtk-3.0.21
- gi-gtk-hs-0.3.6.1
- gi-pango-1.0.16 - gi-pango-1.0.16
- gi-xlib-2.0.2 - gi-xlib-2.0.2
- gio-0.13.4.1 - gio-0.13.4.1
- gtk-sni-tray-0.1.3.0 - gtk-sni-tray-0.1.3.1
- gtk-strut-0.1.2.0 - gtk-strut-0.1.2.1
- gtk-traymanager-1.0.1 - gtk-traymanager-1.0.1
- gtk3-0.14.9 - gtk3-0.14.9
- haskell-gi-0.21.2 - haskell-gi-0.21.2

@ -1 +1 @@
Subproject commit 441f16f381c66e22d95054a605ebc348012b93ad Subproject commit e6f0bf2e08300e6dc5405131549fc21a6e9af7f0

View File

@ -1,17 +1,35 @@
@define-color bg-color #000000; @define-color transparent rgba(0.0, 0.0, 0.0, 0.0);
@define-color bg-tone #1E1E20; @define-color white #FFFFFF;
@define-color active-window-color #374140; @define-color black #000000;
@define-color urgent-window-color #D9CB9E; @define-color taffy-blue #0c7cd5;
@define-color font-color #FFFFFF;
.InnerPad { @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 * {
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: 5px; padding-bottom: 5px;
padding-top: 5px; padding-top: 5px;
padding-left: 2px; padding-left: 2px;
padding-right: 2px; padding-right: 2px;
} }
.Contents { .contents {
padding-bottom: 4px; padding-bottom: 4px;
padding-top: 4px; padding-top: 4px;
padding-right: 2px; padding-right: 2px;
@ -20,94 +38,84 @@
border-radius: 5px; border-radius: 5px;
} }
.Active .Contents, .Visible .Contents { /* Workspaces styling */
.workspace-label {
padding-right: 3px;
padding-left: 2px;
font-size: 12pt;
}
.active .contents {
background-color: rgba(0.0, 0.0, 0.0, 0.5); background-color: rgba(0.0, 0.0, 0.0, 0.5);
} }
.WorkspaceLabel { .visible .contents {
padding-right: 3px; background-color: rgba(0.0, 0.0, 0.0, 0.2);
padding-left: 2px;
font-size: 10pt;
} }
.Windows * { .window-icon-container {
color: @bg-color; transition: opacity .5s, box-shadow .5s;
border-color: @bg-color;
}
.TrayContainer {
background-color: @urgent-window-color;
padding: 20px;
}
.TrayWidget {
background-color: @urgent-window-color;
padding: 20px;
}
.TrayWidgetContainer {
background-color: @urgent-window-color;
padding: 20px;
}
.TaffyBox {
border-bottom: solid;
border-width: 1px;
border-color: #FFFFFF;
background-color: rgba(0.0, 0.0, 0.0, 0.3);
}
.Taffybar * {
font-family: "Noto Sans", sans-serif;
font-size: 10pt;
color: @font-color;
}
.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;
}
.IconImage {
transition: opacity .5s, background-color .5s;
opacity: 1;
padding-bottom: 1px;
padding-top: 1px;
}
.IconContainer {
border-bottom: 0px;
transition: opacity .5s, box-shadow 1s;
padding-bottom: 4px;
opacity: 1; opacity: 1;
} }
.IconContainer.Active { /* This gives space for the box-shadow (they look like underlines) that follow.
border-color: rgba(255, 255, 255, 1.0); This will actually affect all widgets, (not just the workspace icons), but
/* background-color: rgba(255, 255, 255, 0.3); */ that is what we want since we want the icons to look the same. */
border-radius: 0px; .auto-size-image, .sni-tray {
opacity: 1; padding-top: 3px;
box-shadow: inset 0 -1px #FFFFFF; padding-bottom: 3px;
} }
.IconContainer.Urgent { .window-icon-container.active {
box-shadow: inset 0 -3px @white;
}
.window-icon-container.urgent {
box-shadow: inset 0 -3px @urgent-window-color; box-shadow: inset 0 -3px @urgent-window-color;
} }
.IconContainer.Minimized .IconImage { .window-icon-container.inactive .window-icon {
transition: opacity .5s; padding: 0px;
}
.window-icon-container.minimized .window-icon {
opacity: .3; 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;
}

View File

@ -1,28 +1,17 @@
{-# LANGUAGE PackageImports #-} {-# LANGUAGE PackageImports #-}
module Main where module Main where
import qualified Control.Concurrent.MVar as MV
import Control.Exception.Base import Control.Exception.Base
import Control.Monad import Control.Monad
import Control.Monad.IO.Class import Control.Monad.IO.Class
import Control.Monad.Trans.Class import Control.Monad.Trans.Class
import Control.Monad.Trans.Reader import Control.Monad.Trans.Reader
import qualified Data.ByteString.Char8 as BS import qualified Data.ByteString.Char8 as BS
import Data.GI.Base
import Data.GI.Base.ManagedPtr
import Data.List import Data.List
import Data.List.Split import Data.List.Split
import qualified Data.Map as M import qualified Data.Map as M
import Data.Maybe import Data.Maybe
import Debug.Trace
import Foreign.ForeignPtr
import Foreign.Ptr
import qualified GI.Gtk as GI
import qualified GitHub.Auth as Auth import qualified GitHub.Auth as Auth
import qualified "gtk3" Graphics.UI.Gtk as Gtk
import qualified "gtk3" Graphics.UI.Gtk.Abstract.Widget as W
import qualified "gtk3" Graphics.UI.Gtk.Layout.Table as T
import Graphics.UI.Gtk.Types
import StatusNotifier.Tray import StatusNotifier.Tray
import System.Directory import System.Directory
import System.Environment import System.Environment
@ -38,7 +27,6 @@ import System.Taffybar.Compat.GtkLibs
import System.Taffybar.DBus import System.Taffybar.DBus
import System.Taffybar.DBus.Toggle import System.Taffybar.DBus.Toggle
import System.Taffybar.Hooks import System.Taffybar.Hooks
import System.Taffybar.IconImages
import System.Taffybar.Information.CPU import System.Taffybar.Information.CPU
import System.Taffybar.Information.EWMHDesktopInfo import System.Taffybar.Information.EWMHDesktopInfo
import System.Taffybar.Information.Memory import System.Taffybar.Information.Memory
@ -51,18 +39,6 @@ import System.Taffybar.Widget.Util
import System.Taffybar.Widget.Workspaces import System.Taffybar.Widget.Workspaces
import Text.Printf import Text.Printf
import Text.Read hiding (lift) import Text.Read hiding (lift)
import Unsafe.Coerce
buildContentsBox widget = liftIO $ do
contents <- Gtk.hBoxNew False 0
Gtk.containerAdd contents widget
_ <- widgetSetClass contents "Contents"
Gtk.widgetShowAll contents
buildPadBox contents
setMinWidth width widget = liftIO $ do
Gtk.widgetSetSizeRequest widget width (-1)
return widget
mkRGBA (r, g, b, a) = (r/256, g/256, b/256, a/256) mkRGBA (r, g, b, a) = (r/256, g/256, b/256, a/256)
blue = mkRGBA (42, 99, 140, 256) blue = mkRGBA (42, 99, 140, 256)
@ -76,7 +52,7 @@ myGraphConfig =
{ graphPadding = 0 { graphPadding = 0
, graphBorderWidth = 0 , graphBorderWidth = 0
, graphWidth = 75 , graphWidth = 75
, graphBackgroundColor = (1.0, 1.0, 1.0, 0.0) , graphBackgroundColor = (0.0, 0.0, 0.0, 0.0)
} }
netCfg = myGraphConfig netCfg = myGraphConfig
@ -112,19 +88,20 @@ workspaceNamesLabelSetter workspace =
liftX11Def [] getFullWorkspaceNames liftX11Def [] getFullWorkspaceNames
logDebug = do logDebug = do
handler <- streamHandler stdout DEBUG logger <- getLogger "System.Taffybar.Widget.Generic.AutoSizeImage"
logger <- getLogger "System.Taffybar"
saveGlobalLogger $ setLevel DEBUG logger saveGlobalLogger $ setLevel DEBUG logger
logger2 <- getLogger "StatusNotifier.Tray"
saveGlobalLogger $ setLevel DEBUG logger2
workspacesLogger <- getLogger "System.Taffybar.Widget.Workspaces" workspacesLogger <- getLogger "System.Taffybar.Widget.Workspaces"
saveGlobalLogger $ setLevel WARNING workspacesLogger saveGlobalLogger $ setLevel WARNING workspacesLogger
github = do -- github = do
Right (token, _) <- passGet "github-token" -- Right (token, _) <- passGet "github-token"
githubNotificationsNew $ defaultGithubConfig $ Auth.OAuth $ BS.pack token -- githubNotificationsNew $ defaultGithubConfig $ Auth.OAuth $ BS.pack token
main = do main = do
homeDirectory <- getHomeDirectory homeDirectory <- getHomeDirectory
logDebug -- logDebug
let resourcesDirectory = homeDirectory </> ".lib" </> "resources" let resourcesDirectory = homeDirectory </> ".lib" </> "resources"
inResourcesDirectory file = resourcesDirectory </> file inResourcesDirectory file = resourcesDirectory </> file
highContrastDirectory = highContrastDirectory =
@ -155,7 +132,7 @@ main = do
, minWSWidgetSize = Nothing , minWSWidgetSize = Nothing
, minIcons = 1 , minIcons = 1
, getIconInfo = myGetIconInfo , getIconInfo = myGetIconInfo
, windowIconSize = 31 -- , windowIconSize = 31
, widgetGap = 0 , widgetGap = 0
, showWorkspaceFn = hideEmpty , showWorkspaceFn = hideEmpty
, updateRateLimitMicroseconds = 100000 , updateRateLimitMicroseconds = 100000
@ -170,22 +147,25 @@ main = do
, textBatteryNew "$percentage$% ($time$)" , textBatteryNew "$percentage$% ($time$)"
, batteryIconNew , batteryIconNew
, sniTrayNew , sniTrayNew
, github -- , github
, cpu , cpu
, mem , mem
, networkGraphNew netCfg Nothing , networkGraphNew netCfg Nothing
-- , networkMonitorNew defaultNetFormat Nothing >>= setMinWidth 200 -- , networkMonitorNew defaultNetFormat Nothing >>= setMinWidth 200
, fsMonitorNew 60 ["/dev/sdd2"] -- , fsMonitorNew 60 ["/dev/sdd2"]
, mpris2New , mpris2New
] ]
, barPosition = Top , barPosition = Top
, barPadding = 0 , barPadding = 5
, barHeight = 55 , barHeight = 50
, widgetSpacing = 0 , widgetSpacing = 0
} }
simpleTaffyConfig = simpleTaffyConfig =
baseConfig baseConfig
dyreTaffybar $ withBatteryRefresh $ withLogServer $ withToggleServer $ -- { endWidgets = []
-- , startWidgets = [flip widgetSetClass "Workspaces" =<< workspaces]
-- }
startTaffybar $ withBatteryRefresh $ withLogServer $ withToggleServer $
toTaffyConfig simpleTaffyConfig toTaffyConfig simpleTaffyConfig
-- Local Variables: -- Local Variables: