summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar/Run
diff options
context:
space:
mode:
Diffstat (limited to 'src/Xmobar/Run')
-rw-r--r--src/Xmobar/Run/Actions.hs6
-rw-r--r--src/Xmobar/Run/Loop.hs6
2 files changed, 10 insertions, 2 deletions
diff --git a/src/Xmobar/Run/Actions.hs b/src/Xmobar/Run/Actions.hs
index cbc10c5..fc9682d 100644
--- a/src/Xmobar/Run/Actions.hs
+++ b/src/Xmobar/Run/Actions.hs
@@ -12,6 +12,7 @@
module Xmobar.Run.Actions ( Button
, Action(..)
+ , isEmpty
, runAction
, runAction'
, stripActions) where
@@ -20,12 +21,17 @@ import System.Process (spawnCommand, waitForProcess)
import Control.Monad (void)
import Text.Regex (Regex, subRegex, mkRegex, matchRegex)
import Data.Word (Word32)
+import Data.Char (isSpace)
type Button = Word32
data Action = Spawn [Button] String deriving (Eq, Read, Show)
+isEmpty :: Action -> Bool
+isEmpty (Spawn _ s) = all isSpace s
+
runAction :: Action -> IO ()
+runAction a | isEmpty a = return ()
runAction (Spawn _ s) = void $ spawnCommand (s ++ " &") >>= waitForProcess
-- | Run action with stdout redirected to stderr
diff --git a/src/Xmobar/Run/Loop.hs b/src/Xmobar/Run/Loop.hs
index 9954cb9..343a857 100644
--- a/src/Xmobar/Run/Loop.hs
+++ b/src/Xmobar/Run/Loop.hs
@@ -28,6 +28,7 @@ import Data.Foldable (for_)
import Xmobar.System.Signal
import Xmobar.Config.Types
+import Xmobar.Config.Template (withEmptyAction)
import Xmobar.Run.Runnable (Runnable)
import Xmobar.Run.Exec (start, trigger, alias)
import Xmobar.Run.Template
@@ -94,14 +95,15 @@ initLoop sig lock vs = do
-- | Runs a command as an independent thread and returns its Async handles
-- and the TVar the command will be writing to.
startCommand :: TMVar SignalType
- -> (Runnable,String,String)
+ -> (Runnable, String, String)
-> IO ([Async ()], TVar String)
startCommand sig (com,s,ss)
| alias com == "" = do var <- newTVarIO is
atomically $ writeTVar var (s ++ ss)
return ([], var)
| otherwise = do var <- newTVarIO is
- let cb str = atomically $ writeTVar var (s ++ str ++ ss)
+ let cb str = atomically $
+ writeTVar var (s ++ withEmptyAction str ++ ss)
a1 <- async $ start com cb
a2 <- async $ trigger com $ maybe (return ())
(atomically . putTMVar sig)