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:
Sibi Prabakaran
2020-05-29 22:19:03 +05:30
parent 28e29fa238
commit 1d0eaddc25

View File

@@ -29,6 +29,7 @@ module XMonad.Util.Run (
spawnPipe,
spawnPipeWithLocaleEncoding,
spawnPipeWithUtf8Encoding,
spawnPipeWithNoEncoding,
hPutStr, hPutStrLn -- re-export for convenience
) where
@@ -148,11 +149,15 @@ runInTerm = unsafeRunInTerm
safeRunInTerm :: String -> String -> X ()
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
-- return a @Handle@ to its standard input. Note that the @Handle@
-- is a binary Handle. You should probably use 'spawnPipeWithUtf8Encoding'.
spawnPipe :: MonadIO m => String -> m Handle
spawnPipe x = io $ do
spawnPipeWithNoEncoding :: MonadIO m => String -> m Handle
spawnPipeWithNoEncoding x = io $ do
(rd, wr) <- createPipe
setFdOption wr CloseOnExec True
h <- fdToHandle wr