| xmonad-contrib-0.8.1: Third party extensions for xmonad | Source code | Contents | Index

XMonad.Util.Run

Portability | unportable
Stability | unstable
Maintainer | Christian Thiemann <mail@christian-thiemann.de>

Contents

Usage

Description
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 :: FilePath -> [String] -> String -> IO String
runProcessWithInputAndWait :: FilePath -> [String] -> String -> Int -> IO ()
safeSpawn :: MonadIO m => FilePath -> String -> m ()
unsafeSpawn :: MonadIO m => String -> m ()
runInTerm :: String -> String -> X ()
safeRunInTerm :: String -> String -> X ()
seconds :: Rational -> Int
spawnPipe :: String -> IO Handle
hPutStr
hPutStrLn

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 :: FilePath -> [String] -> String -> IO String | Source

Return output if the command succeeded, otherwise return `()`. This corresponds to dmenu's notion of exit code 1 for a cancelled invocation.

runProcessWithInputAndWait :: FilePath -> [String] -> String -> Int -> IO () | Source

Wait is in s (microseconds)

safeSpawn :: MonadIO m => FilePath -> String -> m () | Source

`safeSpawn` bypasses XMonad.Core's `spawn` command, 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. unsafeSpawn is internally an alias for XMonad's `spawn`, to remind one that use of it can be, well, unsafe. Examples:

     , ((modMask, xK_Print), unsafeSpawn "import -window root $HOME/xwd-$(date +%s)$$.png")
     , ((modMask, 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.

unsafeSpawn :: MonadIO m => String -> m () | Source

runInTerm :: String -> String -> X () | Source

Open a terminal emulator. The terminal emulator is specified in `defaultConfig` 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`

safeRunInTerm :: String -> String -> X () | Source

Run a given program in the preferred terminal emulator; see `runInTerm`. This makes use of `safeSpawn`.

seconds :: Rational -> Int | Source

Multiplies by ONE MILLION, for functions that take microseconds.

Use like:

     (5.5 `seconds`)

spawnPipe :: String -> IO Handle | Source

Launch an external application through the system shell and return a `Handle` to its standard input.
hPutStr
hPutStrLn
Produced by Haddock version 2.4.2