summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar/App/Main.hs
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/Main.hs
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/Main.hs')
-rw-r--r--src/Xmobar/App/Main.hs6
1 files changed, 5 insertions, 1 deletions
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)