summaryrefslogtreecommitdiffhomepage
path: root/readme.md
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2012-08-22 22:42:01 +0200
committerJose Antonio Ortega Ruiz <jao@gnu.org>2012-08-22 22:42:01 +0200
commite7cadcd8dee8c2e79e338f67cb27b675aba6bac5 (patch)
treec0c470e5a0f19b6d53e6772b079197442bb9bf57 /readme.md
parent8e87d8671c06eb5acca3a4c92e569e1dba253160 (diff)
parenta05c57f7aed141a8d6dc9038be177712be432b9d (diff)
downloadxmobar-e7cadcd8dee8c2e79e338f67cb27b675aba6bac5.tar.gz
xmobar-e7cadcd8dee8c2e79e338f67cb27b675aba6bac5.tar.bz2
Merge remote-tracking branch 'jrk/dbusstuff' into jrk
Diffstat (limited to 'readme.md')
-rw-r--r--readme.md64
1 files changed, 63 insertions, 1 deletions
diff --git a/readme.md b/readme.md
index 05f441f..2d18f67 100644
--- a/readme.md
+++ b/readme.md
@@ -340,9 +340,71 @@ An example using the `dbus-send` command line utility:
"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"
+ "string:ChangeScreen" "string:Reveal 0" "string:TogglePersistent"
+
+### Example for using the DBus IPC interface with XMonad
+
+Bind the key which should {,un}map xmobar to a dummy value. This is necessary
+for {,un}grabKey in xmonad.
+
+ ((0, xK_Alt_L ), return ())
+
+Also, install `avoidStruts` layout modifier from `XMonad.Hooks.ManageDocks`
+
+Finally, install these two event hooks (`handleEventHook` in `XConfig`)
+`myDocksEventHook` is a replacement for `docksEventHook` which reacts on unmap
+events as well (which `docksEventHook` doesn't).
+
+ import qualified XMonad.Util.ExtensibleState as XS
+
+ data DockToggleTime = DTT { lastTime :: Time } deriving (Eq, Show, Typeable)
+
+ instance ExtensionClass DockToggleTime where
+ initialValue = DTT 0
+
+ toggleDocksHook :: Int -> KeySym -> Event -> X All
+ toggleDocksHook to ks ( KeyEvent { ev_event_display = d
+ , ev_event_type = et
+ , ev_keycode = ekc
+ , ev_time = etime
+ } ) =
+ io (keysymToKeycode d ks) >>= toggleDocks >> return (All True)
+ where
+ toggleDocks kc
+ | ekc == kc && et == keyPress = do
+ safeSendSignal ["Reveal 0", "TogglePersistent"]
+ XS.put ( DTT etime )
+ | ekc == kc && et == keyRelease = do
+ gap <- XS.gets ( (-) etime . lastTime )
+ safeSendSignal [ "TogglePersistent"
+ , "Hide " ++ show (if gap < 400 then to else 0)
+ ]
+ | otherwise = return ()
+
+ safeSendSignal s = catchX (io $ sendSignal s) (return ())
+ sendSignal = withSession . callSignal
+ withSession mc = connectSession >>= \c -> callNoReply c mc >> disconnect c
+ callSignal :: [String] -> MethodCall
+ callSignal s = ( methodCall
+ ( objectPath_ "/org/Xmobar/Control" )
+ ( interfaceName_ "org.Xmobar.Control" )
+ ( memberName_ "SendSignal" )
+ ) { methodCallDestination = Just $ busName_ "org.Xmobar.Control"
+ , methodCallBody = map toVariant s
+ }
+
+ toggleDocksHook _ _ _ = return (All True)
+
+ myDocksEventHook :: Event -> X All
+ myDocksEventHook e = do
+ when (et == mapNotify || et == unmapNotify) $
+ whenX ((not `fmap` (isClient w)) <&&> runQuery checkDock w) refresh
+ return (All True)
+ where w = ev_window e
+ et = ev_event_type e
## The Output Template