diff options
-rw-r--r-- | src/IPC/DBus.hs | 9 | ||||
-rw-r--r-- | src/Signal.hs | 18 |
2 files changed, 18 insertions, 9 deletions
diff --git a/src/IPC/DBus.hs b/src/IPC/DBus.hs index 4357c48..b0597a4 100644 --- a/src/IPC/DBus.hs +++ b/src/IPC/DBus.hs @@ -16,19 +16,12 @@ module IPC.DBus ( runIPC ) where import DBus import DBus.Client -import Control.Monad ((>=>), join, when) +import Control.Monad (join, when) import Control.Concurrent import Signal import Plugins.Utils (safeHead) -instance IsVariant SignalType where - toVariant = toVariant . show - fromVariant = fromVariant >=> parseSignalType - -parseSignalType :: String -> Maybe SignalType -parseSignalType = fmap fst . safeHead . reads - busName :: BusName busName = busName_ "org.Xmobar.Control" diff --git a/src/Signal.hs b/src/Signal.hs index ad19fdd..f634c16 100644 --- a/src/Signal.hs +++ b/src/Signal.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE DeriveDataTypeable, CPP #-} module Signal where @@ -7,6 +7,13 @@ import Control.Concurrent import Control.Exception hiding (handle) import System.Posix.Signals +#ifdef DBUS +import DBus (IsVariant(..)) +import Control.Monad ((>=>)) + +import Plugins.Utils (safeHead) +#endif + data WakeUp = WakeUp deriving (Show,Typeable) instance Exception WakeUp @@ -19,6 +26,15 @@ data SignalType = Wakeup | TogglePersistent deriving (Read, Show) +#ifdef DBUS +instance IsVariant SignalType where + toVariant = toVariant . show + fromVariant = fromVariant >=> parseSignalType +#endif + +parseSignalType :: String -> Maybe SignalType +parseSignalType = fmap fst . safeHead . reads + -- | Signal handling setupSignalHandler :: IO (MVar SignalType) setupSignalHandler = do |