[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-gio-2.0.16
- gi-gtk-3.0.21
- gi-gtk-hs-0.3.6.1
- gi-pango-1.0.16
- gi-xlib-2.0.2
- gio-0.13.4.1
- gtk-sni-tray-0.1.3.0
- gtk-strut-0.1.2.0
- gtk-sni-tray-0.1.3.1
- gtk-strut-0.1.2.1
- gtk-traymanager-1.0.1
- gtk3-0.14.9
- 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 bg-tone #1E1E20;
@define-color active-window-color #374140;
@define-color urgent-window-color #D9CB9E;
@define-color font-color #FFFFFF;
@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;
.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-top: 5px;
padding-left: 2px;
padding-right: 2px;
}
.Contents {
.contents {
padding-bottom: 4px;
padding-top: 4px;
padding-right: 2px;
@ -20,94 +38,84 @@
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);
}
.WorkspaceLabel {
padding-right: 3px;
padding-left: 2px;
font-size: 10pt;
.visible .contents {
background-color: rgba(0.0, 0.0, 0.0, 0.2);
}
.Windows * {
color: @bg-color;
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;
.window-icon-container {
transition: opacity .5s, box-shadow .5s;
opacity: 1;
}
.IconContainer.Active {
border-color: rgba(255, 255, 255, 1.0);
/* background-color: rgba(255, 255, 255, 0.3); */
border-radius: 0px;
opacity: 1;
box-shadow: inset 0 -1px #FFFFFF;
/* 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;
}
.IconContainer.Urgent {
.window-icon-container.active {
box-shadow: inset 0 -3px @white;
}
.window-icon-container.urgent {
box-shadow: inset 0 -3px @urgent-window-color;
}
.IconContainer.Minimized .IconImage {
transition: opacity .5s;
.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;
}

View File

@ -1,28 +1,17 @@
{-# LANGUAGE PackageImports #-}
module Main where
import qualified Control.Concurrent.MVar as MV
import Control.Exception.Base
import Control.Monad
import Control.Monad.IO.Class
import Control.Monad.Trans.Class
import Control.Monad.Trans.Reader
import qualified Data.ByteString.Char8 as BS
import Data.GI.Base
import Data.GI.Base.ManagedPtr
import Data.List
import Data.List.Split
import qualified Data.Map as M
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 "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 System.Directory
import System.Environment
@ -38,7 +27,6 @@ import System.Taffybar.Compat.GtkLibs
import System.Taffybar.DBus
import System.Taffybar.DBus.Toggle
import System.Taffybar.Hooks
import System.Taffybar.IconImages
import System.Taffybar.Information.CPU
import System.Taffybar.Information.EWMHDesktopInfo
import System.Taffybar.Information.Memory
@ -51,18 +39,6 @@ import System.Taffybar.Widget.Util
import System.Taffybar.Widget.Workspaces
import Text.Printf
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)
blue = mkRGBA (42, 99, 140, 256)
@ -76,7 +52,7 @@ myGraphConfig =
{ graphPadding = 0
, graphBorderWidth = 0
, graphWidth = 75
, graphBackgroundColor = (1.0, 1.0, 1.0, 0.0)
, graphBackgroundColor = (0.0, 0.0, 0.0, 0.0)
}
netCfg = myGraphConfig
@ -112,19 +88,20 @@ workspaceNamesLabelSetter workspace =
liftX11Def [] getFullWorkspaceNames
logDebug = do
handler <- streamHandler stdout DEBUG
logger <- getLogger "System.Taffybar"
logger <- getLogger "System.Taffybar.Widget.Generic.AutoSizeImage"
saveGlobalLogger $ setLevel DEBUG logger
logger2 <- getLogger "StatusNotifier.Tray"
saveGlobalLogger $ setLevel DEBUG logger2
workspacesLogger <- getLogger "System.Taffybar.Widget.Workspaces"
saveGlobalLogger $ setLevel WARNING workspacesLogger
github = do
Right (token, _) <- passGet "github-token"
githubNotificationsNew $ defaultGithubConfig $ Auth.OAuth $ BS.pack token
-- github = do
-- Right (token, _) <- passGet "github-token"
-- githubNotificationsNew $ defaultGithubConfig $ Auth.OAuth $ BS.pack token
main = do
homeDirectory <- getHomeDirectory
logDebug
-- logDebug
let resourcesDirectory = homeDirectory </> ".lib" </> "resources"
inResourcesDirectory file = resourcesDirectory </> file
highContrastDirectory =
@ -155,7 +132,7 @@ main = do
, minWSWidgetSize = Nothing
, minIcons = 1
, getIconInfo = myGetIconInfo
, windowIconSize = 31
-- , windowIconSize = 31
, widgetGap = 0
, showWorkspaceFn = hideEmpty
, updateRateLimitMicroseconds = 100000
@ -170,23 +147,26 @@ main = do
, textBatteryNew "$percentage$% ($time$)"
, batteryIconNew
, sniTrayNew
, github
-- , github
, cpu
, mem
, networkGraphNew netCfg Nothing
-- , networkMonitorNew defaultNetFormat Nothing >>= setMinWidth 200
, fsMonitorNew 60 ["/dev/sdd2"]
-- , fsMonitorNew 60 ["/dev/sdd2"]
, mpris2New
]
, barPosition = Top
, barPadding = 0
, barHeight = 55
, barPadding = 5
, barHeight = 50
, widgetSpacing = 0
}
simpleTaffyConfig =
baseConfig
dyreTaffybar $ withBatteryRefresh $ withLogServer $ withToggleServer $
toTaffyConfig simpleTaffyConfig
-- { endWidgets = []
-- , startWidgets = [flip widgetSetClass "Workspaces" =<< workspaces]
-- }
startTaffybar $ withBatteryRefresh $ withLogServer $ withToggleServer $
toTaffyConfig simpleTaffyConfig
-- Local Variables:
-- flycheck-ghc-args: ("-Wno-missing-signatures")