From 082ef98c1c265ad927b728402d8803a86bbbaeef Mon Sep 17 00:00:00 2001 From: jao Date: Mon, 18 Apr 2022 15:59:51 +0100 Subject: New dbus signal: SetAlpha (fixes #499) --- changelog.md | 1 + doc/quick-start.org | 20 +++++++++++--------- doc/window-managers.org | 10 +++++----- src/Xmobar/System/Signal.hs | 1 + src/Xmobar/X11/Loop.hs | 3 +++ 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/changelog.md b/changelog.md index 7c652b1..f9767bf 100644 --- a/changelog.md +++ b/changelog.md @@ -5,6 +5,7 @@ _New features_ - New monitor `Load` providing load averages (stolen from Finn Lawler, with FreeBSD support thanks to MichaƂ Zielonka). - New argument `scale` for `Memory` monitor to scale size units. + - New dbus signal: `SetAlpha` (see issue #499). _Bug fixes_ diff --git a/doc/quick-start.org b/doc/quick-start.org index 831f97c..929deb6 100644 --- a/doc/quick-start.org +++ b/doc/quick-start.org @@ -428,12 +428,13 @@ available [[http://github.com/jaor/xmobar/raw/master/examples/xmobar.config][her When compiled with the optional =with_dbus= flag, xmobar can be controlled over dbus. All signals defined in [[https://github.com/jaor/xmobar/blob/master/src/Xmobar/System/Signal.hs][src/Signal.hs]] as =data - SignalType= can now be sent over dbus to xmobar. Due to current - limitations of the implementation only one process of xmobar can - acquire the dbus. This is handled on a first-come-first-served - basis, meaning that the first process will get the dbus - interface. Other processes will run without further problems, yet - have no dbus interface. + SignalType= can now be sent over dbus to xmobar. + + Due to current limitations of the implementation only one process of + xmobar can acquire the dbus. This is handled on a + first-come-first-served basis, meaning that the first process will + get the dbus interface. Other processes will run without further + problems, yet have no dbus interface. - Bus Name: =org.Xmobar.Control= - Object Path: =/org/Xmobar/Control= @@ -450,7 +451,7 @@ available [[http://github.com/jaor/xmobar/raw/master/examples/xmobar.config][her --print-reply \ '/org/Xmobar/Control' \ org.Xmobar.Control.SendSignal \ - "string:Toggle 0" + "string:SetAlpha 192" #+end_src It is also possible to send multiple signals at once: @@ -463,7 +464,8 @@ available [[http://github.com/jaor/xmobar/raw/master/examples/xmobar.config][her The =Toggle=, =Reveal=, and =Hide= signals take an additional integer argument that denotes an initial delay, in tenths of a second, - before the command takes effect. + 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 + See [[./window-managers.org::*Example of using][Interfacing with window managers]] for an example of how to use the DBus interface from xmonad. diff --git a/doc/window-managers.org b/doc/window-managers.org index e45784c..f60ee37 100644 --- a/doc/window-managers.org +++ b/doc/window-managers.org @@ -219,7 +219,7 @@ choice. xmonad configuration (=xmonad.hs=), e.g. by using a custom =~/.xmonad/build= script. -*** Example for using the DBus IPC interface with XMonad +*** Example of 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. @@ -245,10 +245,10 @@ choice. toggleDocksHook :: Int -> KeySym -> Event -> X All toggleDocksHook to ks ( KeyEvent { ev_event_display = d - , ev_event_type = et - , ev_keycode = ekc - , ev_time = etime - } ) = + , ev_event_type = et + , ev_keycode = ekc + , ev_time = etime + } ) = io (keysymToKeycode d ks) >>= toggleDocks >> return (All True) where toggleDocks kc diff --git a/src/Xmobar/System/Signal.hs b/src/Xmobar/System/Signal.hs index 3983654..81a4481 100644 --- a/src/Xmobar/System/Signal.hs +++ b/src/Xmobar/System/Signal.hs @@ -46,6 +46,7 @@ data SignalType = Wakeup | Hide Int | Reveal Int | Toggle Int + | SetAlpha Int | TogglePersistent | Action Button Position deriving (Read, Show) diff --git a/src/Xmobar/X11/Loop.hs b/src/Xmobar/X11/Loop.hs index 9c1a0f0..631855c 100644 --- a/src/Xmobar/X11/Loop.hs +++ b/src/Xmobar/X11/Loop.hs @@ -39,6 +39,7 @@ import qualified Data.List.NonEmpty as NE import Xmobar.System.Signal import Xmobar.Config.Types ( persistent + , alpha , font , additionalFonts , textOffset @@ -146,6 +147,8 @@ signalLoop xc@(XConf d r w fs vos is cfg) as signal tv = do TogglePersistent -> signalLoop xc { config = cfg { persistent = not $ persistent cfg } } as signal tv + SetAlpha a -> signalLoop xc { config = cfg { alpha = a}} as signal tv + Action but x -> action but x where -- cgit v1.2.3