summaryrefslogtreecommitdiffhomepage
path: root/src/Signal.hs
diff options
context:
space:
mode:
authorJochen Keil <jochen.keil@gmail.com>2012-08-10 11:38:52 +0200
committerJochen Keil <jochen.keil@gmail.com>2012-08-10 11:38:52 +0200
commitb318c3c18d3c2d4866c3f325f8ec6f00a42876fb (patch)
treeb1ab4ad8bc69fd4955b4933c5043c59072ab591e /src/Signal.hs
parent1f603c25eea15d302a4aa1ebb879bbd8198a3b82 (diff)
downloadxmobar-b318c3c18d3c2d4866c3f325f8ec6f00a42876fb.tar.gz
xmobar-b318c3c18d3c2d4866c3f325f8ec6f00a42876fb.tar.bz2
Move the IsVariant SignalType instance to Signal module
This belongs here, otherwise ghc will complain about orphaned instances
Diffstat (limited to 'src/Signal.hs')
-rw-r--r--src/Signal.hs18
1 files changed, 17 insertions, 1 deletions
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