diff options
author | jao <jao@gnu.org> | 2022-07-24 17:14:52 +0100 |
---|---|---|
committer | jao <jao@gnu.org> | 2022-07-24 17:14:52 +0100 |
commit | 232a6d435a36f99b72e49bfb8d58f37a0377841b (patch) | |
tree | 590ee7ccc36e626da825437aaa82deb88e3d8bdb | |
parent | ead65d18d521ba37f523f21008b373b23cd9612d (diff) | |
download | xmobar-232a6d435a36f99b72e49bfb8d58f37a0377841b.tar.gz xmobar-232a6d435a36f99b72e49bfb8d58f37a0377841b.tar.bz2 |
documentation: interfacing-with-window-managers.org gone
-rw-r--r-- | doc/plugins.org | 8 | ||||
-rw-r--r-- | doc/quick-start.org | 66 | ||||
-rw-r--r-- | doc/window-managers.org | 69 | ||||
-rw-r--r-- | readme.org | 7 |
4 files changed, 71 insertions, 79 deletions
diff --git a/doc/plugins.org b/doc/plugins.org index 6f388c1..558bdef 100644 --- a/doc/plugins.org +++ b/doc/plugins.org @@ -35,9 +35,8 @@ 100 #+end_src - See also [[./window-managers.org][Interfacing with window managers]] for a collection of - plugins that let you interact and control xmobar from window - managers. + See also [[#interfacing-with-window-managers][Interfacing with window managers]] below for a collection of plugins + that let you interact and control xmobar from window managers. ** Icon Patterns @@ -1328,6 +1327,9 @@ - Default template: =Up: <days>d <hours>h <minutes>m= * Interfacing with window managers + :PROPERTIES: + :CUSTOM_ID: interfacing-with-window-managers + :END: ** Property-based logging *** =XMonadLog= diff --git a/doc/quick-start.org b/doc/quick-start.org index 2557295..5ae9d1a 100644 --- a/doc/quick-start.org +++ b/doc/quick-start.org @@ -469,5 +469,67 @@ available [[https://codeberg.org/xmobar/xmobar/src/branch/master/examples/xmobar before the command takes effect, while =SetAlpha= takes a new alpha value (also an integer, between 0 and 255) as argument. - See [[./window-managers.org::*Example of using][Interfacing with window managers]] for an example of how to use - the DBus interface from xmonad. +** Example: 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. + + #+begin_src haskell + ((0, xK_Alt_L), pure ()) + #+end_src + + 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). + + #+begin_src haskell + 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 + #+end_src diff --git a/doc/window-managers.org b/doc/window-managers.org deleted file mode 100644 index 92bc651..0000000 --- a/doc/window-managers.org +++ /dev/null @@ -1,69 +0,0 @@ -#+title: Interfacing with window managers - -Listed below are ways to interface xmobar with your window manager of -choice. - -* 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. - - #+begin_src haskell - ((0, xK_Alt_L), pure ()) - #+end_src - - 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). - - #+begin_src haskell - 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 - #+end_src @@ -180,15 +180,12 @@ channel, ~#xmobar~, at [[ircs://irc.libera.chat][Libera]]. - If you want to get a detailed overview of all available plugins and monitors, visit the [[./doc/plugins.org][plugins index]]. - - [[./doc/window-managers.org][Interfacing with window managers]] describes plugins and extensions - for interacting with xmobar from your window manager. + - For elaborated examples of how to use xmobar as a Haskell library see the + [[file:doc/using-haskell.org][using Haskell docs]]. - If you want to know how to contribute to the xmobar project, check out [[contributing.org][contributing]]. - - For elaborated examples of how to use xmobar as a Haskell library see the - [[file:doc/using-haskell.org][using Haskell docs]]. - * Authors and credits Andrea Rossato originally designed and implemented xmobar up to |