summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/Xmobar/Plugins/Monitors/Batt/Common.hs9
-rw-r--r--src/Xmobar/Run/Actions.hs7
2 files changed, 8 insertions, 8 deletions
diff --git a/src/Xmobar/Plugins/Monitors/Batt/Common.hs b/src/Xmobar/Plugins/Monitors/Batt/Common.hs
index 2c60155..31caabc 100644
--- a/src/Xmobar/Plugins/Monitors/Batt/Common.hs
+++ b/src/Xmobar/Plugins/Monitors/Batt/Common.hs
@@ -20,7 +20,7 @@ module Xmobar.Plugins.Monitors.Batt.Common (BattOpts(..)
, maybeAlert) where
import System.Environment
-import System.Process (waitForProcess, createProcess_, shell, CreateProcess(env))
+import System.Process (waitForProcess, withCreateProcess, shell, CreateProcess(env))
import Control.Monad (unless, void)
import Xmobar.Plugins.Monitors.Common
@@ -60,8 +60,7 @@ maybeAlert opts left =
where
mkShellCmd command = do
selfEnv <- getEnvironment
- pure (shell command) { env = Just $ [("XMOBAR_BATT_LEFT", show @Int $ round $ 100 * left)] ++ selfEnv
+ pure (shell command) { env = Just $ ("XMOBAR_BATT_LEFT", show @Int $ round $ 100 * left) : selfEnv
}
- runCmd c = do
- (_,_,_,p) <- createProcess_ "maybeAlert" c
- void $ waitForProcess p
+ runCmd c = withCreateProcess c $ \_ _ _ ph ->
+ void $ waitForProcess ph
diff --git a/src/Xmobar/Run/Actions.hs b/src/Xmobar/Run/Actions.hs
index cbc10c5..a9afed9 100644
--- a/src/Xmobar/Run/Actions.hs
+++ b/src/Xmobar/Run/Actions.hs
@@ -16,7 +16,7 @@ module Xmobar.Run.Actions ( Button
, runAction'
, stripActions) where
-import System.Process (spawnCommand, waitForProcess)
+import System.Process (shell, withCreateProcess, waitForProcess)
import Control.Monad (void)
import Text.Regex (Regex, subRegex, mkRegex, matchRegex)
import Data.Word (Word32)
@@ -26,11 +26,12 @@ type Button = Word32
data Action = Spawn [Button] String deriving (Eq, Read, Show)
runAction :: Action -> IO ()
-runAction (Spawn _ s) = void $ spawnCommand (s ++ " &") >>= waitForProcess
+runAction (Spawn _ s) = withCreateProcess (shell s) $ \_ _ _ ph ->
+ void $ waitForProcess ph
-- | Run action with stdout redirected to stderr
runAction' :: Action -> IO ()
-runAction' (Spawn _ s) = void $ spawnCommand (s ++ " 1>&2 &") >>= waitForProcess
+runAction' (Spawn btn s) = runAction (Spawn btn (s ++ " 1>&2"))
stripActions :: String -> String
stripActions s = case matchRegex actionRegex s of