summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/Xmobar.hs4
-rw-r--r--src/Xmobar/App/EventLoop.hs2
-rw-r--r--src/Xmobar/Plugins/BufferedPipeReader.hs2
-rw-r--r--src/Xmobar/Plugins/CommandReader.hs2
-rw-r--r--src/Xmobar/Plugins/Date.hs2
-rw-r--r--src/Xmobar/Plugins/DateZone.hs2
-rw-r--r--src/Xmobar/Plugins/EWMH.hs2
-rw-r--r--src/Xmobar/Plugins/Kbd.hs2
-rw-r--r--src/Xmobar/Plugins/Locks.hs2
-rw-r--r--src/Xmobar/Plugins/MBox.hs2
-rw-r--r--src/Xmobar/Plugins/Mail.hs2
-rw-r--r--src/Xmobar/Plugins/MarqueePipeReader.hs2
-rw-r--r--src/Xmobar/Plugins/Monitors.hs2
-rw-r--r--src/Xmobar/Plugins/Monitors/Common/Run.hs2
-rw-r--r--src/Xmobar/Plugins/PipeReader.hs2
-rw-r--r--src/Xmobar/Plugins/StdinReader.hs2
-rw-r--r--src/Xmobar/Plugins/XMonadLog.hs2
-rw-r--r--src/Xmobar/Run/Command.hs55
-rw-r--r--src/Xmobar/Run/Exec.hs (renamed from src/Xmobar/Run/Commands.hs)38
-rw-r--r--src/Xmobar/Run/Runnable.hs2
-rw-r--r--src/Xmobar/Run/Runnable.hs-boot2
-rw-r--r--src/Xmobar/Run/Template.hs3
-rw-r--r--src/Xmobar/Run/Types.hs4
-rw-r--r--xmobar.cabal3
24 files changed, 84 insertions, 59 deletions
diff --git a/src/Xmobar.hs b/src/Xmobar.hs
index 4f912a2..ac51c01 100644
--- a/src/Xmobar.hs
+++ b/src/Xmobar.hs
@@ -20,6 +20,7 @@ module Xmobar (xmobar
, defaultConfig
, Runnable (..)
, Exec (..)
+ , Command (..)
, module Xmobar.Config.Types
, module Xmobar.Config.Parse
, module Xmobar.Plugins.BufferedPipeReader
@@ -42,7 +43,8 @@ module Xmobar (xmobar
) where
import Xmobar.Run.Runnable
-import Xmobar.Run.Commands
+import Xmobar.Run.Exec
+import Xmobar.Run.Command
import Xmobar.Config.Types
import Xmobar.Config.Parse
import Xmobar.Plugins.BufferedPipeReader
diff --git a/src/Xmobar/App/EventLoop.hs b/src/Xmobar/App/EventLoop.hs
index 7a76ee6..678db2d 100644
--- a/src/Xmobar/App/EventLoop.hs
+++ b/src/Xmobar/App/EventLoop.hs
@@ -38,7 +38,7 @@ import Data.Maybe (fromJust, isJust)
import Xmobar.System.Signal
import Xmobar.Config.Types
-import Xmobar.Run.Commands
+import Xmobar.Run.Exec
import Xmobar.Run.Runnable
import Xmobar.X11.Actions
import Xmobar.X11.Parsers
diff --git a/src/Xmobar/Plugins/BufferedPipeReader.hs b/src/Xmobar/Plugins/BufferedPipeReader.hs
index ee02355..f98d0d4 100644
--- a/src/Xmobar/Plugins/BufferedPipeReader.hs
+++ b/src/Xmobar/Plugins/BufferedPipeReader.hs
@@ -20,7 +20,7 @@ import Control.Concurrent.STM
import System.IO
import System.IO.Unsafe(unsafePerformIO)
-import Xmobar.Run.Commands
+import Xmobar.Run.Exec
import Xmobar.System.Signal
import Xmobar.System.Environment
import Xmobar.System.Utils(hGetLineSafe)
diff --git a/src/Xmobar/Plugins/CommandReader.hs b/src/Xmobar/Plugins/CommandReader.hs
index 4e39d72..9cf6d0e 100644
--- a/src/Xmobar/Plugins/CommandReader.hs
+++ b/src/Xmobar/Plugins/CommandReader.hs
@@ -16,7 +16,7 @@
module Xmobar.Plugins.CommandReader(CommandReader(..)) where
import System.IO
-import Xmobar.Run.Commands
+import Xmobar.Run.Exec
import Xmobar.System.Utils (hGetLineSafe)
import System.Process(runInteractiveCommand, getProcessExitCode)
diff --git a/src/Xmobar/Plugins/Date.hs b/src/Xmobar/Plugins/Date.hs
index 62a4ee7..1cb0596 100644
--- a/src/Xmobar/Plugins/Date.hs
+++ b/src/Xmobar/Plugins/Date.hs
@@ -19,7 +19,7 @@
module Xmobar.Plugins.Date (Date(..)) where
-import Xmobar.Run.Commands
+import Xmobar.Run.Exec
#if ! MIN_VERSION_time(1,5,0)
import System.Locale
diff --git a/src/Xmobar/Plugins/DateZone.hs b/src/Xmobar/Plugins/DateZone.hs
index c2e80da..22be6c2 100644
--- a/src/Xmobar/Plugins/DateZone.hs
+++ b/src/Xmobar/Plugins/DateZone.hs
@@ -22,7 +22,7 @@
module Xmobar.Plugins.DateZone (DateZone(..)) where
-import Xmobar.Run.Commands
+import Xmobar.Run.Exec
#ifdef DATEZONE
import Control.Concurrent.STM
diff --git a/src/Xmobar/Plugins/EWMH.hs b/src/Xmobar/Plugins/EWMH.hs
index 5b68620..6440940 100644
--- a/src/Xmobar/Plugins/EWMH.hs
+++ b/src/Xmobar/Plugins/EWMH.hs
@@ -22,7 +22,7 @@ import Control.Monad.State
import Control.Monad.Reader
import Graphics.X11 hiding (Modifier, Color)
import Graphics.X11.Xlib.Extras
-import Xmobar.Run.Commands
+import Xmobar.Run.Exec
#ifdef UTF8
#undef UTF8
import Codec.Binary.UTF8.String as UTF8
diff --git a/src/Xmobar/Plugins/Kbd.hs b/src/Xmobar/Plugins/Kbd.hs
index 6654163..a8a8cdc 100644
--- a/src/Xmobar/Plugins/Kbd.hs
+++ b/src/Xmobar/Plugins/Kbd.hs
@@ -20,7 +20,7 @@ import Control.Monad (forever)
import Graphics.X11.Xlib
import Graphics.X11.Xlib.Extras
-import Xmobar.Run.Commands
+import Xmobar.Run.Exec
import Xmobar.X11.Events (nextEvent')
import Xmobar.System.Kbd
diff --git a/src/Xmobar/Plugins/Locks.hs b/src/Xmobar/Plugins/Locks.hs
index 25d2946..9176312 100644
--- a/src/Xmobar/Plugins/Locks.hs
+++ b/src/Xmobar/Plugins/Locks.hs
@@ -19,7 +19,7 @@ import Data.List
import Data.Bits
import Control.Monad
import Graphics.X11.Xlib.Extras
-import Xmobar.Run.Commands
+import Xmobar.Run.Exec
import Xmobar.System.Kbd
import Xmobar.X11.Events (nextEvent')
diff --git a/src/Xmobar/Plugins/MBox.hs b/src/Xmobar/Plugins/MBox.hs
index 7eaa998..311f26e 100644
--- a/src/Xmobar/Plugins/MBox.hs
+++ b/src/Xmobar/Plugins/MBox.hs
@@ -16,7 +16,7 @@
module Xmobar.Plugins.MBox (MBox(..)) where
import Prelude
-import Xmobar.Run.Commands
+import Xmobar.Run.Exec
#ifdef INOTIFY
import Xmobar.System.Utils (changeLoop, expandHome)
diff --git a/src/Xmobar/Plugins/Mail.hs b/src/Xmobar/Plugins/Mail.hs
index e67817b..7325087 100644
--- a/src/Xmobar/Plugins/Mail.hs
+++ b/src/Xmobar/Plugins/Mail.hs
@@ -15,7 +15,7 @@
module Xmobar.Plugins.Mail(Mail(..)) where
-import Xmobar.Run.Commands
+import Xmobar.Run.Exec
#ifdef INOTIFY
import Xmobar.System.Utils (expandHome, changeLoop)
diff --git a/src/Xmobar/Plugins/MarqueePipeReader.hs b/src/Xmobar/Plugins/MarqueePipeReader.hs
index a139aba..28e9ed5 100644
--- a/src/Xmobar/Plugins/MarqueePipeReader.hs
+++ b/src/Xmobar/Plugins/MarqueePipeReader.hs
@@ -16,7 +16,7 @@ module Xmobar.Plugins.MarqueePipeReader where
import System.IO (openFile, IOMode(ReadWriteMode), Handle)
import Xmobar.System.Environment
-import Xmobar.Run.Commands(Exec(alias, start), tenthSeconds)
+import Xmobar.Run.Exec(Exec(alias, start), tenthSeconds)
import Xmobar.System.Utils(hGetLineSafe)
import System.Posix.Files (getFileStatus, isNamedPipe)
import Control.Concurrent(forkIO, threadDelay)
diff --git a/src/Xmobar/Plugins/Monitors.hs b/src/Xmobar/Plugins/Monitors.hs
index fe909d8..3e7584f 100644
--- a/src/Xmobar/Plugins/Monitors.hs
+++ b/src/Xmobar/Plugins/Monitors.hs
@@ -17,7 +17,7 @@
module Xmobar.Plugins.Monitors where
-import Xmobar.Run.Commands
+import Xmobar.Run.Exec
import Xmobar.Plugins.Monitors.Common (runM, runMD)
#ifdef WEATHER
diff --git a/src/Xmobar/Plugins/Monitors/Common/Run.hs b/src/Xmobar/Plugins/Monitors/Common/Run.hs
index 5422d71..74a7695 100644
--- a/src/Xmobar/Plugins/Monitors/Common/Run.hs
+++ b/src/Xmobar/Plugins/Monitors/Common/Run.hs
@@ -27,7 +27,7 @@ import Control.Monad.Reader
import System.Console.GetOpt
import Xmobar.Plugins.Monitors.Common.Types
-import Xmobar.Run.Commands (tenthSeconds)
+import Xmobar.Run.Exec (tenthSeconds)
options :: [OptDescr Opts]
options =
diff --git a/src/Xmobar/Plugins/PipeReader.hs b/src/Xmobar/Plugins/PipeReader.hs
index d7b6a56..9c6e628 100644
--- a/src/Xmobar/Plugins/PipeReader.hs
+++ b/src/Xmobar/Plugins/PipeReader.hs
@@ -15,7 +15,7 @@
module Xmobar.Plugins.PipeReader(PipeReader(..)) where
import System.IO
-import Xmobar.Run.Commands(Exec(..))
+import Xmobar.Run.Exec(Exec(..))
import Xmobar.System.Utils(hGetLineSafe)
import Xmobar.System.Environment(expandEnv)
import System.Posix.Files
diff --git a/src/Xmobar/Plugins/StdinReader.hs b/src/Xmobar/Plugins/StdinReader.hs
index 7f5f2ae..4b80044 100644
--- a/src/Xmobar/Plugins/StdinReader.hs
+++ b/src/Xmobar/Plugins/StdinReader.hs
@@ -23,7 +23,7 @@ import System.Posix.Process
import System.Exit
import System.IO
import Control.Exception (SomeException(..), handle)
-import Xmobar.Run.Commands
+import Xmobar.Run.Exec
import Xmobar.X11.Actions (stripActions)
import Xmobar.System.Utils (hGetLineSafe)
diff --git a/src/Xmobar/Plugins/XMonadLog.hs b/src/Xmobar/Plugins/XMonadLog.hs
index 8261980..0bf62e1 100644
--- a/src/Xmobar/Plugins/XMonadLog.hs
+++ b/src/Xmobar/Plugins/XMonadLog.hs
@@ -20,7 +20,7 @@ module Xmobar.Plugins.XMonadLog (XMonadLog(..)) where
import Control.Monad
import Graphics.X11
import Graphics.X11.Xlib.Extras
-import Xmobar.Run.Commands
+import Xmobar.Run.Exec
#ifdef UTF8
#undef UTF8
import Codec.Binary.UTF8.String as UTF8
diff --git a/src/Xmobar/Run/Command.hs b/src/Xmobar/Run/Command.hs
new file mode 100644
index 0000000..0953132
--- /dev/null
+++ b/src/Xmobar/Run/Command.hs
@@ -0,0 +1,55 @@
+------------------------------------------------------------------------------
+-- |
+-- Module: Xmobar.Plugins.Command
+-- Copyright: (c) 2018 Jose Antonio Ortega Ruiz
+-- License: BSD3-style (see LICENSE)
+--
+-- Maintainer: jao@gnu.org
+-- Stability: unstable
+-- Portability: portable
+-- Created: Sun Dec 02, 2018 05:29
+--
+--
+-- The basic Command plugin
+--
+------------------------------------------------------------------------------
+
+
+module Xmobar.Run.Command where
+
+import Control.Exception (handle, SomeException(..))
+import System.Process
+import System.Exit
+import System.IO (hClose)
+import Xmobar.System.Utils (hGetLineSafe)
+
+import Xmobar.Run.Exec
+
+data Command = Com Program Args Alias Rate
+ | ComX Program Args String Alias Rate
+ deriving (Show,Read,Eq)
+
+type Args = [String]
+type Program = String
+type Alias = String
+type Rate = Int
+
+instance Exec Command where
+ 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
+ exit <- waitForProcess p
+ let closeHandles = hClose o >> hClose i >> hClose e
+ getL = handle (\(SomeException _) -> return "")
+ (hGetLineSafe o)
+ case exit of
+ ExitSuccess -> do str <- getL
+ closeHandles
+ cb str
+ _ -> closeHandles >> cb msg
diff --git a/src/Xmobar/Run/Commands.hs b/src/Xmobar/Run/Exec.hs
index 2aac344..c8fcb9e 100644
--- a/src/Xmobar/Run/Commands.hs
+++ b/src/Xmobar/Run/Exec.hs
@@ -1,6 +1,6 @@
-----------------------------------------------------------------------------
-- |
--- Module : Xmobar.Commands
+-- Module : Xmobar.Exec
-- Copyright : (c) Andrea Rossato
-- License : BSD-style (see LICENSE)
--
@@ -17,18 +17,13 @@
--
-----------------------------------------------------------------------------
-module Xmobar.Run.Commands (Command (..), Exec (..), tenthSeconds) where
+module Xmobar.Run.Exec (Exec (..), tenthSeconds) where
import Prelude
-import Control.Exception (handle, SomeException(..))
import Data.Char
-import System.Process
-import System.Exit
-import System.IO (hClose)
import Control.Concurrent
import Xmobar.System.Signal
-import Xmobar.System.Utils (hGetLineSafe)
-- | Work around to the Int max bound: since threadDelay takes an Int, it
-- is not possible to set a thread delay grater than about 45 minutes.
@@ -51,32 +46,3 @@ class Show e => Exec e where
where go = run e >>= cb >> tenthSeconds (rate e) >> go
trigger :: e -> (Maybe SignalType -> IO ()) -> IO ()
trigger _ sh = sh Nothing
-
-data Command = Com Program Args Alias Rate
- | ComX Program Args String Alias Rate
- deriving (Show,Read,Eq)
-
-type Args = [String]
-type Program = String
-type Alias = String
-type Rate = Int
-
-instance Exec Command where
- 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
- exit <- waitForProcess p
- let closeHandles = hClose o >> hClose i >> hClose e
- getL = handle (\(SomeException _) -> return "")
- (hGetLineSafe o)
- case exit of
- ExitSuccess -> do str <- getL
- closeHandles
- cb str
- _ -> closeHandles >> cb msg
diff --git a/src/Xmobar/Run/Runnable.hs b/src/Xmobar/Run/Runnable.hs
index 962166e..068a05b 100644
--- a/src/Xmobar/Run/Runnable.hs
+++ b/src/Xmobar/Run/Runnable.hs
@@ -24,7 +24,7 @@ module Xmobar.Run.Runnable where
import Control.Monad
import Text.Read
import Xmobar.Run.Types (runnableTypes)
-import Xmobar.Run.Commands
+import Xmobar.Run.Exec
data Runnable = forall r . (Exec r, Read r, Show r) => Run r
diff --git a/src/Xmobar/Run/Runnable.hs-boot b/src/Xmobar/Run/Runnable.hs-boot
index f272d81..1cd1688 100644
--- a/src/Xmobar/Run/Runnable.hs-boot
+++ b/src/Xmobar/Run/Runnable.hs-boot
@@ -1,6 +1,6 @@
{-# LANGUAGE ExistentialQuantification #-}
module Xmobar.Run.Runnable where
-import Xmobar.Run.Commands
+import Xmobar.Run.Exec
data Runnable = forall r . (Exec r,Read r,Show r) => Run r
diff --git a/src/Xmobar/Run/Template.hs b/src/Xmobar/Run/Template.hs
index 749edcd..50c3a08 100644
--- a/src/Xmobar/Run/Template.hs
+++ b/src/Xmobar/Run/Template.hs
@@ -20,7 +20,8 @@ module Xmobar.Run.Template(parseTemplate, splitTemplate) where
import qualified Data.Map as Map
import Text.ParserCombinators.Parsec
-import Xmobar.Run.Commands
+import Xmobar.Run.Exec
+import Xmobar.Run.Command
import Xmobar.Run.Runnable
defaultAlign :: String
diff --git a/src/Xmobar/Run/Types.hs b/src/Xmobar/Run/Types.hs
index 4fb526a..f4a7252 100644
--- a/src/Xmobar/Run/Types.hs
+++ b/src/Xmobar/Run/Types.hs
@@ -18,8 +18,6 @@
module Xmobar.Run.Types(runnableTypes) where
-import Xmobar.Run.Commands
-
import {-# SOURCE #-} Xmobar.Run.Runnable()
import Xmobar.Plugins.Monitors
import Xmobar.Plugins.Date
@@ -42,6 +40,8 @@ import Xmobar.Plugins.MBox
import Xmobar.Plugins.DateZone
#endif
+import Xmobar.Run.Command
+
-- | An alias for tuple types that is more convenient for long lists.
type a :*: b = (a, b)
infixr :*:
diff --git a/xmobar.cabal b/xmobar.cabal
index 0fb9772..1c75761 100644
--- a/xmobar.cabal
+++ b/xmobar.cabal
@@ -101,7 +101,8 @@ library
Xmobar.Config.Parse,
Xmobar.Run.Types,
Xmobar.Run.Template,
- Xmobar.Run.Commands,
+ Xmobar.Run.Exec,
+ Xmobar.Run.Command,
Xmobar.Run.Runnable
Xmobar.App.EventLoop,
Xmobar.App.Config,