summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2018-07-19 22:11:14 +0100
committerjao <jao@gnu.org>2018-07-19 22:11:14 +0100
commitcbde794c899d04524a486d5d0f82b8e2d889cdb8 (patch)
treefadf5babc1b9ffffec1fc3f060c332366e505fb1 /src
parent82e186a112ac0d76a139ed572fb24b45a6b83967 (diff)
downloadxmobar-cbde794c899d04524a486d5d0f82b8e2d889cdb8.tar.gz
xmobar-cbde794c899d04524a486d5d0f82b8e2d889cdb8.tar.bz2
New ComX specifying error output string (closes #342)
Diffstat (limited to 'src')
-rw-r--r--src/Commands.hs14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/Commands.hs b/src/Commands.hs
index e4402fc..5b11ca3 100644
--- a/src/Commands.hs
+++ b/src/Commands.hs
@@ -48,6 +48,7 @@ class Show e => Exec e where
trigger _ sh = sh Nothing
data Command = Com Program Args Alias Rate
+ | ComX Program Args String Alias Rate
deriving (Show,Read,Eq)
type Args = [String]
@@ -56,10 +57,12 @@ type Alias = String
type Rate = Int
instance Exec Command where
- alias (Com p _ a _)
- | p /= "" = if a == "" then p else a
- | otherwise = ""
- start (Com prog args _ r) cb = if r > 0 then go else exec
+ alias (ComX p _ _ a _) =
+ if p /= "" then (if a == "" then p else a) else ""
+ alias (Com p a al r) = alias (ComX p a "" al r)
+ start (Com p as al r) cb =
+ start (ComX p as ("Could not execute command " ++ p) al r) cb
+ start (ComX prog args msg _ r) cb = if r > 0 then go else exec
where go = exec >> tenthSeconds r >> go
exec = do
(i,o,e,p) <- runInteractiveProcess prog args Nothing Nothing
@@ -71,8 +74,7 @@ instance Exec Command where
ExitSuccess -> do str <- getL
closeHandles
cb str
- _ -> do closeHandles
- cb $ "Could not execute command " ++ prog
+ _ -> closeHandles >> cb msg
-- | Work around to the Int max bound: since threadDelay takes an Int, it