[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.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,6 +62,7 @@ instance WorkspaceWidgetController Gtk.Widget where
makeContents waction klass = do
widget <- waction
liftIO $ do
widgetSetClass widget "Contents"
widgetSetClass widget klass
b <- buildPadBox widget
@ -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