mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-03 21:51:52 -07:00
Make spawnPipe to use system's locale encoding
Add a function named spawnPipeWithNoEncoding for people who might want to use binary handles. Fixes https://github.com/xmonad/xmonad-contrib/issues/338
This commit is contained in:
@@ -29,6 +29,7 @@ module XMonad.Util.Run (
|
|||||||
spawnPipe,
|
spawnPipe,
|
||||||
spawnPipeWithLocaleEncoding,
|
spawnPipeWithLocaleEncoding,
|
||||||
spawnPipeWithUtf8Encoding,
|
spawnPipeWithUtf8Encoding,
|
||||||
|
spawnPipeWithNoEncoding,
|
||||||
hPutStr, hPutStrLn -- re-export for convenience
|
hPutStr, hPutStrLn -- re-export for convenience
|
||||||
) where
|
) where
|
||||||
|
|
||||||
@@ -148,11 +149,15 @@ runInTerm = unsafeRunInTerm
|
|||||||
safeRunInTerm :: String -> String -> X ()
|
safeRunInTerm :: String -> String -> X ()
|
||||||
safeRunInTerm options command = asks (terminal . config) >>= \t -> safeSpawn t [options, " -e " ++ command]
|
safeRunInTerm options command = asks (terminal . config) >>= \t -> safeSpawn t [options, " -e " ++ command]
|
||||||
|
|
||||||
|
-- | Same as 'spawnPipeWithLocaleEncoding'
|
||||||
|
spawnPipe :: MonadIO m => String -> m Handle
|
||||||
|
spawnPipe = spawnPipeWithLocaleEncoding
|
||||||
|
|
||||||
-- | Launch an external application through the system shell and
|
-- | Launch an external application through the system shell and
|
||||||
-- return a @Handle@ to its standard input. Note that the @Handle@
|
-- return a @Handle@ to its standard input. Note that the @Handle@
|
||||||
-- is a binary Handle. You should probably use 'spawnPipeWithUtf8Encoding'.
|
-- is a binary Handle. You should probably use 'spawnPipeWithUtf8Encoding'.
|
||||||
spawnPipe :: MonadIO m => String -> m Handle
|
spawnPipeWithNoEncoding :: MonadIO m => String -> m Handle
|
||||||
spawnPipe x = io $ do
|
spawnPipeWithNoEncoding x = io $ do
|
||||||
(rd, wr) <- createPipe
|
(rd, wr) <- createPipe
|
||||||
setFdOption wr CloseOnExec True
|
setFdOption wr CloseOnExec True
|
||||||
h <- fdToHandle wr
|
h <- fdToHandle wr
|
||||||
|
Reference in New Issue
Block a user