From 0ee656c0b0d6a836bdaa9adb60010203c8afaa73 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Sun, 22 Apr 2018 23:14:56 -0700 Subject: [PATCH 1/2] [taffybar] Use taffybar provided SNI tray --- dotfiles/config/taffybar/taffybar | 2 +- dotfiles/config/taffybar/taffybar.hs | 34 ++++++++++++---------------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/dotfiles/config/taffybar/taffybar b/dotfiles/config/taffybar/taffybar index 1c2dbadc..accf7df7 160000 --- a/dotfiles/config/taffybar/taffybar +++ b/dotfiles/config/taffybar/taffybar @@ -1 +1 @@ -Subproject commit 1c2dbadc40ce23a54a465bc072b1fce208c9be7e +Subproject commit accf7df727f20f030dc91d7648f9b6f2cd68ca9a diff --git a/dotfiles/config/taffybar/taffybar.hs b/dotfiles/config/taffybar/taffybar.hs index c42e1896..643e430e 100644 --- a/dotfiles/config/taffybar/taffybar.hs +++ b/dotfiles/config/taffybar/taffybar.hs @@ -5,6 +5,7 @@ import qualified Control.Concurrent.MVar as MV import Control.Exception.Base import Control.Monad import Control.Monad.Reader +import Control.Monad.Trans import Data.GI.Base import Data.GI.Base.ManagedPtr import Data.List @@ -38,9 +39,9 @@ import System.Taffybar.IconImages import System.Taffybar.LayoutSwitcher import System.Taffybar.MPRIS2 import System.Taffybar.NetMonitor +import System.Taffybar.SNITray import System.Taffybar.SimpleClock import System.Taffybar.SimpleConfig -import System.Taffybar.Systray import System.Taffybar.ToggleMonitor import System.Taffybar.Widgets.PollingGraph import System.Taffybar.WindowSwitcher @@ -49,7 +50,7 @@ import Text.Printf import Text.Read hiding (lift) import Unsafe.Coerce -data ConstantIconController = ConstantIconController { cicImage :: Gtk.Image } +newtype ConstantIconController = ConstantIconController { cicImage :: Gtk.Image } instance WorkspaceWidgetController ConstantIconController where updateWidget cic _ = return cic @@ -61,11 +62,12 @@ instance WorkspaceWidgetController Gtk.Widget where makeContents waction klass = do widget <- waction - widgetSetClass widget "Contents" - widgetSetClass widget klass - b <- buildPadBox widget - Gtk.widgetShowAll b - return $ Gtk.toWidget b + liftIO $ do + widgetSetClass widget "Contents" + widgetSetClass widget klass + b <- buildPadBox widget + Gtk.widgetShowAll b + return $ Gtk.toWidget b myGraphConfig = defaultGraphConfig @@ -108,7 +110,7 @@ cpuCallback = do return [totalLoad, systemLoad] containerAddReturn c w = - Gtk.containerAdd c w >> Gtk.widgetShowAll c >> (return $ Gtk.toWidget c) + Gtk.containerAdd c w >> Gtk.widgetShowAll c >> return (Gtk.toWidget c) underlineWidget cfg buildWidget name = do w <- buildWidget @@ -143,17 +145,9 @@ addClass klass action = do (buildWidgetCons, _) = mkWidget -buildSNITray = do - -- XXX: this won't work for multiple taffybars because it will attempt to - -- register a second host with a name that already exists on the dbus tray. - -- Need to take an approach similar to that of gtk-sni-tray to get that to - -- work. - GI.Widget trayGIWidgetMP <- buildTrayWithHost GI.OrientationHorizontal - wrapNewGObject mkWidget (castPtr <$> disownManagedPtr trayGIWidgetMP) - logDebug = do handler <- streamHandler stdout DEBUG - logger <- getLogger "System.Taffybar" + logger <- getLogger "System" saveGlobalLogger $ setLevel DEBUG logger main = do @@ -237,15 +231,15 @@ main = do defaultSimpleTaffyConfig { startWidgets = [hud, los, addClass "WindowSwitcher" wnd] , centerWidgets = [] - , endWidgets = map lift + , endWidgets = [ batteryBarNew defaultBatteryConfig 1.0 + , makeContents buildSNITray "Cpu" , makeContents clock "Cpu" -- , makeContents systrayNew "Cpu" - , makeContents buildSNITray "Cpu" , makeContents cpu "Cpu" , makeContents mem "Cpu" , makeContents netMonitor "Cpu" - , makeContents (join $ containerAddReturn <$> Gtk.eventBoxNew <*> mpris) "Cpu" + , mpris ] , barPosition = Top , barPadding = 5 From 7ada3f8b9fc345dfa566653552ea744c8494c218 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Sun, 22 Apr 2018 23:15:23 -0700 Subject: [PATCH 2/2] Add bifunctors to imalison-global stack project --- dotfiles/lib/bin/imalison-global.cabal | 1 + 1 file changed, 1 insertion(+) diff --git a/dotfiles/lib/bin/imalison-global.cabal b/dotfiles/lib/bin/imalison-global.cabal index baa3c71b..c8196303 100644 --- a/dotfiles/lib/bin/imalison-global.cabal +++ b/dotfiles/lib/bin/imalison-global.cabal @@ -6,6 +6,7 @@ library hs-source-dirs: . build-depends: base >= 4.7 && < 5 , split + , bifunctors , containers , regex-compat default-language: Haskell2010