summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJochen Keil <jochen.keil@gmail.com>2012-08-22 17:29:37 +0200
committerJochen Keil <jochen.keil@gmail.com>2012-08-22 17:29:37 +0200
commitd52278f48d98f116d3a1ebd21000bf80d90b8c9d (patch)
tree0496a95d3dadc2adb6371894aa6c9e36b2d05831
parentfb22226dbca8a167d1458766ebfc949ab5c1a1ef (diff)
downloadxmobar-d52278f48d98f116d3a1ebd21000bf80d90b8c9d.tar.gz
xmobar-d52278f48d98f116d3a1ebd21000bf80d90b8c9d.tar.bz2
Allow multiple signals over dbus at once
It's easy to implement, since arguments to dbus method calls are handed over as list anyway. It also removes the need for safeHead. Bottom line: extra functionality without extra cost.
-rw-r--r--readme.md5
-rw-r--r--src/IPC/DBus.hs7
2 files changed, 8 insertions, 4 deletions
diff --git a/readme.md b/readme.md
index 6af1568..7bb7adb 100644
--- a/readme.md
+++ b/readme.md
@@ -339,6 +339,11 @@ An example using the `dbus-send` command line utility:
org.Xmobar.Control.SendSignal \
"string:Toggle"
+It is also possible to send multiple signals at once:
+ # send to another screen, reveal and toggle the persistent flag
+ dbus-send [..] \
+ "string:ChangeScreen" "string:Reveal" "string:TogglePersistent"
+
## The Output Template
diff --git a/src/IPC/DBus.hs b/src/IPC/DBus.hs
index 469a7c6..d755220 100644
--- a/src/IPC/DBus.hs
+++ b/src/IPC/DBus.hs
@@ -18,13 +18,12 @@ import Prelude hiding (catch)
import DBus
import DBus.Client
-import Control.Monad (join, when)
+import Control.Monad (when)
import Control.Concurrent
import Control.Exception (catch)
import System.IO (stderr, hPutStrLn)
import Signal
-import Plugins.Utils (safeHead)
busName :: BusName
busName = busName_ "org.Xmobar.Control"
@@ -56,8 +55,8 @@ sendSignalMethod mvst = method interfaceName sendSignalName
sendSignalMethodCall :: MethodCall -> IO Reply
sendSignalMethodCall mc = do
- when ( methodCallMember mc == sendSignalName ) $ sendSignal $
- join $ safeHead $ map fromVariant $ methodCallBody mc
+ when ( methodCallMember mc == sendSignalName )
+ $ mapM_ (sendSignal . fromVariant) (methodCallBody mc)
return ( replyReturn [] )
sendSignal :: Maybe SignalType -> IO ()