Run.hs, SshPrompt.hs, ShellPrompt.hs: mv runInXTerm back into Run.hs per suggestions

This commit is contained in:
gwern0
2007-10-24 00:13:41 +00:00
parent 725b3a82ca
commit 877999d890
3 changed files with 8 additions and 8 deletions

7
Run.hs
View File

@@ -22,10 +22,12 @@ module XMonadContrib.Run (
runProcessWithInputAndWait, runProcessWithInputAndWait,
safeSpawn, safeSpawn,
unsafeSpawn, unsafeSpawn,
runInXTerm,
seconds seconds
) where ) where
import Control.Monad.State (Monad((>>), return), when) import Control.Monad.State (Monad((>>), return), when)
import System.Environment (getEnv)
import System.Posix.Process (createSession, forkProcess, executeFile, import System.Posix.Process (createSession, forkProcess, executeFile,
getProcessStatus) getProcessStatus)
import Control.Concurrent (threadDelay) import Control.Concurrent (threadDelay)
@@ -102,3 +104,8 @@ safeSpawn :: FilePath -> String -> X ()
safeSpawn prog arg = io (try (forkProcess $ executeFile prog True [arg] Nothing) >> return ()) safeSpawn prog arg = io (try (forkProcess $ executeFile prog True [arg] Nothing) >> return ())
unsafeSpawn :: String -> X () unsafeSpawn :: String -> X ()
unsafeSpawn = spawn unsafeSpawn = spawn
runInXTerm :: String -> X ()
runInXTerm com = do
c <- io $ catch (getEnv "XTERMCMD") (const $ return "xterm")
spawn ("exec " ++ c ++ " -e " ++ com)

View File

@@ -20,7 +20,6 @@ module XMonadContrib.ShellPrompt (
, split , split
, prompt , prompt
, safePrompt , safePrompt
, runInXTerm
) where ) where
import System.Environment (getEnv) import System.Environment (getEnv)
@@ -76,12 +75,6 @@ safePrompt c config = mkXPrompt Shell config (getShellCompl [c]) run
unsafePrompt c config = mkXPrompt Shell config (getShellCompl [c]) run unsafePrompt c config = mkXPrompt Shell config (getShellCompl [c]) run
where run a = unsafeSpawn $ c ++ " " ++ a where run a = unsafeSpawn $ c ++ " " ++ a
-- This may be better done as a specialization of 'prompt'
runInXTerm :: String -> X ()
runInXTerm com = do
c <- io $ catch (getEnv "XTERMCMD") (const $ return "xterm")
spawn ("exec " ++ c ++ " -e " ++ com)
getShellCompl :: [String] -> String -> IO [String] getShellCompl :: [String] -> String -> IO [String]
getShellCompl cmds s | s == "" || last s == ' ' = return [] getShellCompl cmds s | s == "" || last s == ' ' = return []
| otherwise = do | otherwise = do

View File

@@ -19,7 +19,6 @@ module XMonadContrib.SshPrompt (
) where ) where
import System.Environment (getEnv) import System.Environment (getEnv)
import XMonadContrib.ShellPrompt (runInXTerm)
import Control.Monad(Monad (return), Functor(..), liftM2, mapM) import Control.Monad(Monad (return), Functor(..), liftM2, mapM)
import Data.List ((++), concat, filter, map, words, lines, takeWhile, take, import Data.List ((++), concat, filter, map, words, lines, takeWhile, take,
sort) sort)
@@ -27,6 +26,7 @@ import Data.Maybe (Maybe(..), catMaybes)
import Data.Set (toList, fromList) import Data.Set (toList, fromList)
import System.Directory (doesFileExist) import System.Directory (doesFileExist)
import XMonad (X, io) import XMonad (X, io)
import XMonadContrib.Run (runInXTerm)
import XMonadContrib.XPrompt (XPrompt(..), XPConfig, mkXPrompt, import XMonadContrib.XPrompt (XPrompt(..), XPConfig, mkXPrompt,
mkComplFunFromList) mkComplFunFromList)
-- $usage -- $usage