FIX nasty error caused by exception when looking at sockets
This commit is contained in:
parent
cdba344695
commit
936a3b16b8
|
@ -128,8 +128,7 @@ runEditor = sometimesIO_ "text editor" "emacs" tree cmd
|
||||||
where
|
where
|
||||||
cmd = spawnCmd myEditor
|
cmd = spawnCmd myEditor
|
||||||
["-c", "-e", doubleQuote "(select-frame-set-input-focus (selected-frame))"]
|
["-c", "-e", doubleQuote "(select-frame-set-input-focus (selected-frame))"]
|
||||||
tree = toAnd_ (sysExe myEditor) (socketExists "emacs" socketName)
|
tree = Only_ $ sysExe myEditor
|
||||||
socketName = (</> "emacs" </> "server") <$> getEnv "XDG_RUNTIME_DIR"
|
|
||||||
|
|
||||||
runFileManager :: SometimesX
|
runFileManager :: SometimesX
|
||||||
runFileManager = sometimesExe "file browser" "pcmanfm" True "pcmanfm"
|
runFileManager = sometimesExe "file browser" "pcmanfm" True "pcmanfm"
|
||||||
|
|
|
@ -119,6 +119,7 @@ import Data.Maybe
|
||||||
import Data.Yaml
|
import Data.Yaml
|
||||||
|
|
||||||
import GHC.Generics (Generic)
|
import GHC.Generics (Generic)
|
||||||
|
import GHC.IO.Exception (ioe_description)
|
||||||
|
|
||||||
import DBus hiding (typeOf)
|
import DBus hiding (typeOf)
|
||||||
import DBus.Client
|
import DBus.Client
|
||||||
|
@ -780,12 +781,10 @@ socketExists n = IOTest_ ("test if " ++ n ++ " socket exists") . socketExists'
|
||||||
socketExists' :: IO FilePath -> IO (Maybe Msg)
|
socketExists' :: IO FilePath -> IO (Maybe Msg)
|
||||||
socketExists' getPath = do
|
socketExists' getPath = do
|
||||||
p <- getPath
|
p <- getPath
|
||||||
e <- fileExist p
|
r <- tryIOError $ getFileStatus p
|
||||||
s <- isSocket <$> getFileStatus p
|
return $ case r of
|
||||||
return $ case (e, s) of
|
Left e -> toErr $ ioe_description e
|
||||||
(True, True) -> Nothing
|
Right s -> if isSocket s then Nothing else toErr $ p ++ " is not a socket"
|
||||||
(False, _) -> toErr $ "could not find socket at " ++ p
|
|
||||||
(_, False) -> toErr $ p ++ " is not a socket"
|
|
||||||
where
|
where
|
||||||
toErr = Just . Msg Error
|
toErr = Just . Msg Error
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue