Copyright | (C) 2007 Spencer Janssen Andrea Rossato glasser@mit.edu |
---|---|
License | BSD-style (see LICENSE) |
Maintainer | Christian Thiemann <mail@christian-thiemann.de> |
Stability | unstable |
Portability | unportable |
Safe Haskell | None |
Language | Haskell2010 |
This modules provides several commands to run an external process. It is composed of functions formerly defined in XMonad.Util.Dmenu (by Spencer Janssen), XMonad.Util.Dzen (by glasser@mit.edu) and XMonad.Util.RunInXTerm (by Andrea Rossato).
Synopsis
- runProcessWithInput :: MonadIO m => FilePath -> [String] -> String -> m String
- runProcessWithInputAndWait :: MonadIO m => FilePath -> [String] -> String -> Int -> m ()
- safeSpawn :: MonadIO m => FilePath -> [String] -> m ()
- safeSpawnProg :: MonadIO m => FilePath -> m ()
- unsafeSpawn :: MonadIO m => String -> m ()
- runInTerm :: String -> String -> X ()
- safeRunInTerm :: String -> String -> X ()
- seconds :: Rational -> Int
- spawnPipe :: MonadIO m => String -> m Handle
- spawnPipeWithLocaleEncoding :: MonadIO m => String -> m Handle
- spawnPipeWithUtf8Encoding :: MonadIO m => String -> m Handle
- spawnPipeWithNoEncoding :: MonadIO m => String -> m Handle
- hPutStr :: Handle -> String -> IO ()
- hPutStrLn :: Handle -> String -> IO ()
Usage
For an example usage of runInTerm
see XMonad.Prompt.Ssh
For an example usage of runProcessWithInput
see
XMonad.Prompt.DirectoryPrompt, XMonad.Util.Dmenu,
XMonad.Prompt.ShellPrompt, XMonad.Actions.WmiiActions,
XMonad.Prompt.WorkspaceDir
For an example usage of runProcessWithInputAndWait
see
XMonad.Util.Dzen
runProcessWithInput :: MonadIO m => FilePath -> [String] -> String -> m String Source #
Returns the output.
runProcessWithInputAndWait :: MonadIO m => FilePath -> [String] -> String -> Int -> m () Source #
Wait is in μ (microseconds)
safeSpawn :: MonadIO m => FilePath -> [String] -> m () Source #
safeSpawn
bypasses spawn
, because spawn passes
strings to /bin/sh to be interpreted as shell commands. This is
often what one wants, but in many cases the passed string will contain
shell metacharacters which one does not want interpreted as such (URLs
particularly often have shell metacharacters like '&' in them). In
this case, it is more useful to specify a file or program to be run
and a string to give it as an argument so as to bypass the shell and
be certain the program will receive the string as you typed it.
Examples:
, ((modm, xK_Print), unsafeSpawn "import -window root $HOME/xwd-$(date +%s)$$.png") , ((modm, xK_d ), safeSpawn "firefox" [])
Note that the unsafeSpawn example must be unsafe and not safe because
it makes use of shell interpretation by relying on $HOME
and
interpolation, whereas the safeSpawn example can be safe because
Firefox doesn't need any arguments if it is just being started.
safeSpawnProg :: MonadIO m => FilePath -> m () Source #
Simplified safeSpawn
; only takes a program (and no arguments):
, ((modm, xK_d ), safeSpawnProg "firefox")
unsafeSpawn :: MonadIO m => String -> m () Source #
runInTerm :: String -> String -> X () Source #
Open a terminal emulator. The terminal emulator is specified in the default configuration as xterm by default. It is then
asked to pass the shell a command with certain options. This is unsafe in the sense of unsafeSpawn
seconds :: Rational -> Int Source #
Multiplies by ONE MILLION, for functions that take microseconds.
Use like:
(5.5 `seconds`)
In GHC 7 and later, you must either enable the PostfixOperators extension (by adding
{-# LANGUAGE PostfixOperators #-}
to the top of your file) or use seconds in prefix form:
seconds 5.5
spawnPipeWithUtf8Encoding :: MonadIO m => String -> m Handle Source #
Same as spawnPipe
, but forces the UTF-8 encoding regardless of locale.
spawnPipeWithNoEncoding :: MonadIO m => String -> m Handle Source #
Same as spawnPipe
, but forces the char8
encoding, so unicode strings
need encodeString
. Should never be needed, but
some X functions return already encoded Strings, so it may possibly be
useful for someone.
hPutStr :: Handle -> String -> IO () #
Computation hPutStr
hdl s
writes the string
s
to the file or channel managed by hdl
.
This operation may fail with:
isFullError
if the device is full; orisPermissionError
if another system resource limit would be exceeded.