From af4390e1f9152ba1bd3142a5ce5b63313e9747f9 Mon Sep 17 00:00:00 2001 From: jao Date: Tue, 11 Feb 2025 04:40:34 +0000 Subject: prototype for onClick method in Exec --- src/Xmobar/Run/Exec.hs | 3 +++ src/Xmobar/Run/Loop.hs | 9 +++++---- src/Xmobar/Run/Runnable.hs | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src/Xmobar/Run') 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 -- cgit v1.2.3