diff options
author | jao <jao@gnu.org> | 2025-02-11 04:40:34 +0000 |
---|---|---|
committer | jao <jao@gnu.org> | 2025-02-11 19:23:53 +0000 |
commit | af4390e1f9152ba1bd3142a5ce5b63313e9747f9 (patch) | |
tree | 16a57104d7700a88b5e9f83f46831530ba2729ce /src/Xmobar/Run | |
parent | 7390d759240785f660cbdb0ca55898732aa12c98 (diff) | |
download | xmobar-af4390e1f9152ba1bd3142a5ce5b63313e9747f9.tar.gz xmobar-af4390e1f9152ba1bd3142a5ce5b63313e9747f9.tar.bz2 |
prototype for onClick method in Execon-click
Diffstat (limited to 'src/Xmobar/Run')
-rw-r--r-- | src/Xmobar/Run/Exec.hs | 3 | ||||
-rw-r--r-- | src/Xmobar/Run/Loop.hs | 9 | ||||
-rw-r--r-- | src/Xmobar/Run/Runnable.hs | 1 |
3 files changed, 9 insertions, 4 deletions
diff --git a/src/Xmobar/Run/Exec.hs b/src/Xmobar/Run/Exec.hs index 1879361..e5c5c8c 100644 --- a/src/Xmobar/Run/Exec.hs +++ b/src/Xmobar/Run/Exec.hs @@ -21,6 +21,7 @@ module Xmobar.Run.Exec (Exec (..), tenthSeconds, doEveryTenthSeconds) where import Prelude import Data.Char +import Data.Word (Word32) import Xmobar.Run.Timer (doEveryTenthSeconds, tenthSeconds) import Xmobar.System.Signal @@ -37,3 +38,5 @@ class Show e => Exec e where where go = doEveryTenthSeconds (rate e) $ run e >>= cb trigger :: e -> (Maybe SignalType -> IO ()) -> IO () trigger _ sh = sh Nothing + onClick :: e -> Word32 -> IO () + onClick _ _ = return () diff --git a/src/Xmobar/Run/Loop.hs b/src/Xmobar/Run/Loop.hs index bda41ff..9954cb9 100644 --- a/src/Xmobar/Run/Loop.hs +++ b/src/Xmobar/Run/Loop.hs @@ -3,7 +3,7 @@ ------------------------------------------------------------------------------ -- | -- Module: Xmobar.Run.Loop --- Copyright: (c) 2022 Jose Antonio Ortega Ruiz +-- Copyright: (c) 2022, 2025 Jose Antonio Ortega Ruiz -- License: BSD3-style (see LICENSE) -- -- Maintainer: jao@gnu.org @@ -53,13 +53,14 @@ refreshLockT var action = do putTMVar var () return r -type LoopFunction = TMVar SignalType -> TVar [String] -> IO () +type LoopFunction = [Runnable] -> TMVar SignalType -> TVar [String] -> IO () loop :: Config -> LoopFunction -> IO () loop conf looper = withDeferSignals $ do cls <- mapM (parseTemplate (commands conf) (sepChar conf)) - (splitTemplate (alignSep conf) (template conf)) + (splitTemplate (alignSep conf) (template conf)) let confSig = unSignalChan (signal conf) + runners = map (\(r, _, _) -> r) (concat cls) sig <- maybe newEmptyTMVarIO pure confSig unless (isJust confSig) $ setupSignalHandler sig refLock <- newRefreshLock @@ -68,7 +69,7 @@ loop conf looper = withDeferSignals $ do cleanupThreads $ \vars -> do tv <- initLoop sig refLock vars - looper sig tv + looper runners sig tv cleanupThreads :: [[([Async ()], a)]] -> IO () cleanupThreads vars = diff --git a/src/Xmobar/Run/Runnable.hs b/src/Xmobar/Run/Runnable.hs index f89f901..a95e70b 100644 --- a/src/Xmobar/Run/Runnable.hs +++ b/src/Xmobar/Run/Runnable.hs @@ -32,6 +32,7 @@ instance Exec Runnable where start (Run a) = start a alias (Run a) = alias a trigger (Run a) = trigger a + onClick (Run a) = onClick a instance Show Runnable where show (Run x) = "Run " ++ show x |