summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar/App
diff options
context:
space:
mode:
authorJohn Soo <jsoo1@asu.edu>2021-09-17 11:31:56 -0700
committerJohn Soo <jsoo1@asu.edu>2021-11-07 17:47:47 -0800
commitb2d9ca5a587c62ee38d04766689f19d3d4a13c1b (patch)
tree2c42b65e83c6ecfbb70f475a2318239a8f2f841e /src/Xmobar/App
parent397953f1c626a3a81b9ef7280d961fb3ce340c56 (diff)
downloadxmobar-b2d9ca5a587c62ee38d04766689f19d3d4a13c1b.tar.gz
xmobar-b2d9ca5a587c62ee38d04766689f19d3d4a13c1b.tar.bz2
Let xmobar be used with a signal TMVar when used from other haskell.
Diffstat (limited to 'src/Xmobar/App')
-rw-r--r--src/Xmobar/App/Config.hs1
-rw-r--r--src/Xmobar/App/EventLoop.hs2
-rw-r--r--src/Xmobar/App/Main.hs6
3 files changed, 7 insertions, 2 deletions
diff --git a/src/Xmobar/App/Config.hs b/src/Xmobar/App/Config.hs
index d17577e..a227681 100644
--- a/src/Xmobar/App/Config.hs
+++ b/src/Xmobar/App/Config.hs
@@ -64,6 +64,7 @@ defaultConfig =
, template = "%StdinReader% }{ " ++
"<fc=#00FF00>%uname%</fc> * <fc=#FF0000>%theDate%</fc>"
, verbose = False
+ , signal = SignalChan Nothing
}
-- | Return the path to the xmobar data directory. This directory is
diff --git a/src/Xmobar/App/EventLoop.hs b/src/Xmobar/App/EventLoop.hs
index 474ff4f..ae68e96 100644
--- a/src/Xmobar/App/EventLoop.hs
+++ b/src/Xmobar/App/EventLoop.hs
@@ -42,7 +42,7 @@ import Data.Maybe (fromJust, isJust)
import qualified Data.List.NonEmpty as NE
import Xmobar.System.Signal
-import Xmobar.Config.Types
+import Xmobar.Config.Types (persistent, position, iconRoot, Config, Align(..), XPosition(..))
import Xmobar.Run.Exec
import Xmobar.Run.Runnable
import Xmobar.X11.Actions
diff --git a/src/Xmobar/App/Main.hs b/src/Xmobar/App/Main.hs
index 61604e0..002ff27 100644
--- a/src/Xmobar/App/Main.hs
+++ b/src/Xmobar/App/Main.hs
@@ -18,12 +18,14 @@
module Xmobar.App.Main (xmobar, xmobarMain, configFromArgs) where
import Control.Concurrent.Async (Async, cancel)
+import Control.Concurrent.STM (TMVar, newEmptyTMVarIO)
import Control.Exception (bracket)
import Control.Monad (unless)
import Data.Foldable (for_)
import qualified Data.Map as Map
import Data.List (intercalate)
+import Data.Maybe (isJust)
import System.Posix.Process (executeFile)
import System.Environment (getArgs)
import System.FilePath ((</>), takeBaseName, takeDirectory, takeExtension)
@@ -53,7 +55,9 @@ xmobar conf = withDeferSignals $ do
fl <- mapM (initFont d) (additionalFonts conf)
cls <- mapM (parseTemplate (commands conf) (sepChar conf))
(splitTemplate (alignSep conf) (template conf))
- sig <- setupSignalHandler
+ let confSig = unSignalChan (signal conf)
+ sig <- maybe newEmptyTMVarIO pure confSig
+ unless (isJust confSig) $ setupSignalHandler sig
refLock <- newRefreshLock
withTimer (refreshLock refLock) $
bracket (mapM (mapM $ startCommand sig) cls)