summaryrefslogtreecommitdiffhomepage
path: root/src/Plugins/Locks.hs
diff options
context:
space:
mode:
authorAnton Vorontsov <anton@enomsg.org>2014-09-16 18:18:30 -0700
committerAnton Vorontsov <anton@enomsg.org>2014-09-16 20:20:11 -0700
commit16f0bee5a49f95aa47e1ab59010f79b62c07710b (patch)
tree98ac768d2d38cad3077b9f3baa130c666c7ab25a /src/Plugins/Locks.hs
parent73053ddf3386604f19b494afd9c234ac50427d6c (diff)
downloadxmobar-16f0bee5a49f95aa47e1ab59010f79b62c07710b.tar.gz
xmobar-16f0bee5a49f95aa47e1ab59010f79b62c07710b.tar.bz2
Locks: Implement event-driven locks indicator
This commit does more fundamental rework of the "Locks" plug-in: now the plug-in is fully event-driven and thus extremely power-efficient, effectively zero CPU consumption while idling.
Diffstat (limited to 'src/Plugins/Locks.hs')
-rw-r--r--src/Plugins/Locks.hs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/Plugins/Locks.hs b/src/Plugins/Locks.hs
index b30eb1b..79b1583 100644
--- a/src/Plugins/Locks.hs
+++ b/src/Plugins/Locks.hs
@@ -20,6 +20,8 @@ import Data.Bits
import Control.Monad
import Graphics.X11.Xlib.Extras
import Plugins
+import Plugins.Kbd
+import XUtil (nextEvent')
data Locks = Locks
deriving (Read, Show)
@@ -46,14 +48,17 @@ run' d root = do
instance Exec Locks where
alias Locks = "locks"
- rate Locks = 2
start Locks cb = do
d <- openDisplay ""
root <- rootWindow d (defaultScreen d)
+ _ <- xkbSelectEventDetails d xkbUseCoreKbd xkbIndicatorStateNotify m m
- forever $ do
+ allocaXEvent $ \ep -> forever $ do
cb =<< run' d root
- tenthSeconds $ rate Locks
+ nextEvent' d ep
+ getEvent ep
closeDisplay d
return ()
+ where
+ m = xkbAllStateComponentsMask