From b2d9ca5a587c62ee38d04766689f19d3d4a13c1b Mon Sep 17 00:00:00 2001 From: John Soo Date: Fri, 17 Sep 2021 11:31:56 -0700 Subject: Let xmobar be used with a signal TMVar when used from other haskell. --- src/Xmobar/Config/Types.hs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/Xmobar/Config/Types.hs') diff --git a/src/Xmobar/Config/Types.hs b/src/Xmobar/Config/Types.hs index c31e460..3cad31c 100644 --- a/src/Xmobar/Config/Types.hs +++ b/src/Xmobar/Config/Types.hs @@ -17,9 +17,12 @@ module Xmobar.Config.Types -- $config Config (..) , XPosition (..), Align (..), Border(..) + , SignalChan (..) ) where +import qualified Control.Concurrent.STM as STM import Xmobar.Run.Runnable (Runnable(..)) +import Xmobar.System.Signal (SignalType) -- $config -- Configuration data type @@ -65,6 +68,7 @@ data Config = -- right text alignment , template :: String -- ^ The output template , verbose :: Bool -- ^ Emit additional debug messages + , signal :: SignalChan -- ^ The signal channel used to send signals to xmobar } deriving (Read, Show) data XPosition = Top @@ -91,3 +95,12 @@ data Border = NoBorder | BottomBM Int | FullBM Int deriving ( Read, Show, Eq ) + +newtype SignalChan = SignalChan { unSignalChan :: Maybe (STM.TMVar SignalType) } + +instance Read SignalChan where + readsPrec _ s = [ (SignalChan Nothing, s) ] + +instance Show SignalChan where + show (SignalChan (Just _)) = "SignalChan (Just )" + show (SignalChan Nothing) = "SignalChan Nothing" -- cgit v1.2.3