[taffybar] Use taffybar provided SNI tray

This commit is contained in:
Ivan Malison 2018-04-22 23:14:56 -07:00
parent b44e57a9f4
commit 0ee656c0b0
No known key found for this signature in database
GPG Key ID: 62530EFBE99DC2F8
2 changed files with 15 additions and 21 deletions

@ -1 +1 @@
Subproject commit 1c2dbadc40ce23a54a465bc072b1fce208c9be7e Subproject commit accf7df727f20f030dc91d7648f9b6f2cd68ca9a

View File

@ -5,6 +5,7 @@ import qualified Control.Concurrent.MVar as MV
import Control.Exception.Base import Control.Exception.Base
import Control.Monad import Control.Monad
import Control.Monad.Reader import Control.Monad.Reader
import Control.Monad.Trans
import Data.GI.Base import Data.GI.Base
import Data.GI.Base.ManagedPtr import Data.GI.Base.ManagedPtr
import Data.List import Data.List
@ -38,9 +39,9 @@ import System.Taffybar.IconImages
import System.Taffybar.LayoutSwitcher import System.Taffybar.LayoutSwitcher
import System.Taffybar.MPRIS2 import System.Taffybar.MPRIS2
import System.Taffybar.NetMonitor import System.Taffybar.NetMonitor
import System.Taffybar.SNITray
import System.Taffybar.SimpleClock import System.Taffybar.SimpleClock
import System.Taffybar.SimpleConfig import System.Taffybar.SimpleConfig
import System.Taffybar.Systray
import System.Taffybar.ToggleMonitor import System.Taffybar.ToggleMonitor
import System.Taffybar.Widgets.PollingGraph import System.Taffybar.Widgets.PollingGraph
import System.Taffybar.WindowSwitcher import System.Taffybar.WindowSwitcher
@ -49,7 +50,7 @@ import Text.Printf
import Text.Read hiding (lift) import Text.Read hiding (lift)
import Unsafe.Coerce import Unsafe.Coerce
data ConstantIconController = ConstantIconController { cicImage :: Gtk.Image } newtype ConstantIconController = ConstantIconController { cicImage :: Gtk.Image }
instance WorkspaceWidgetController ConstantIconController where instance WorkspaceWidgetController ConstantIconController where
updateWidget cic _ = return cic updateWidget cic _ = return cic
@ -61,11 +62,12 @@ instance WorkspaceWidgetController Gtk.Widget where
makeContents waction klass = do makeContents waction klass = do
widget <- waction widget <- waction
widgetSetClass widget "Contents" liftIO $ do
widgetSetClass widget klass widgetSetClass widget "Contents"
b <- buildPadBox widget widgetSetClass widget klass
Gtk.widgetShowAll b b <- buildPadBox widget
return $ Gtk.toWidget b Gtk.widgetShowAll b
return $ Gtk.toWidget b
myGraphConfig = myGraphConfig =
defaultGraphConfig defaultGraphConfig
@ -108,7 +110,7 @@ cpuCallback = do
return [totalLoad, systemLoad] return [totalLoad, systemLoad]
containerAddReturn c w = 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 underlineWidget cfg buildWidget name = do
w <- buildWidget w <- buildWidget
@ -143,17 +145,9 @@ addClass klass action = do
(buildWidgetCons, _) = mkWidget (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 logDebug = do
handler <- streamHandler stdout DEBUG handler <- streamHandler stdout DEBUG
logger <- getLogger "System.Taffybar" logger <- getLogger "System"
saveGlobalLogger $ setLevel DEBUG logger saveGlobalLogger $ setLevel DEBUG logger
main = do main = do
@ -237,15 +231,15 @@ main = do
defaultSimpleTaffyConfig defaultSimpleTaffyConfig
{ startWidgets = [hud, los, addClass "WindowSwitcher" wnd] { startWidgets = [hud, los, addClass "WindowSwitcher" wnd]
, centerWidgets = [] , centerWidgets = []
, endWidgets = map lift , endWidgets =
[ batteryBarNew defaultBatteryConfig 1.0 [ batteryBarNew defaultBatteryConfig 1.0
, makeContents buildSNITray "Cpu"
, makeContents clock "Cpu" , makeContents clock "Cpu"
-- , makeContents systrayNew "Cpu" -- , makeContents systrayNew "Cpu"
, makeContents buildSNITray "Cpu"
, makeContents cpu "Cpu" , makeContents cpu "Cpu"
, makeContents mem "Cpu" , makeContents mem "Cpu"
, makeContents netMonitor "Cpu" , makeContents netMonitor "Cpu"
, makeContents (join $ containerAddReturn <$> Gtk.eventBoxNew <*> mpris) "Cpu" , mpris
] ]
, barPosition = Top , barPosition = Top
, barPadding = 5 , barPadding = 5