diff options
| -rw-r--r-- | src/Xmobar/Plugins/Accordion.hs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/Xmobar/Plugins/Accordion.hs b/src/Xmobar/Plugins/Accordion.hs index c1967c2..6a1d8e8 100644 --- a/src/Xmobar/Plugins/Accordion.hs +++ b/src/Xmobar/Plugins/Accordion.hs @@ -25,8 +25,9 @@ import Control.Monad.Reader (runReaderT, ask) import Control.Monad.State.Strict (evalStateT, get, modify') import Data.IORef (atomicModifyIORef', newIORef, readIORef, IORef) import Data.Maybe (isJust) +import GHC.IO.Handle.FD (withFileBlocking) import System.Directory (removeFile) -import System.Exit (ExitCode(..)) +import System.IO (IOMode(ReadMode), hGetContents') import System.Process (readProcessWithExitCode) import Xmobar.Run.Exec (Exec(..), tenthSeconds) @@ -74,10 +75,8 @@ instance (Exec a, Read a, Show a) => Exec (Accordion a) where (_, n, _) <- readProcessWithExitCode "uuidgen" [] "" let pipe = "/tmp/accordion-" ++ removeLinebreak n (_, _, _) <- readProcessWithExitCode "mkfifo" [pipe] "" - withAsync (forever $ do (ret, _, _) <- readProcessWithExitCode "cat" [pipe] "" - case ret of - ExitSuccess -> atomicModifyIORef' clicked (const (Just (), ())) - ExitFailure _ -> error "how is this possible?") + withAsync (forever $ do "" <- withFileBlocking pipe ReadMode hGetContents' + atomicModifyIORef' clicked (const (Just (), ()))) (const $ do strRefs <- mapM (newIORef . const "") runnables strRefs' <- mapM (newIORef . const "") shortRunnables @@ -110,4 +109,4 @@ removeLinebreak :: [a] -> [a] removeLinebreak = init attachClick :: String -> String -> String -attachClick file icon = "<action=`echo 1 > " ++ file ++ "`>" ++ icon ++ "</action>" +attachClick file icon = "<action=`echo -n > " ++ file ++ "`>" ++ icon ++ "</action>" |
