diff options
| -rw-r--r-- | src/Xmobar/App/Compile.hs | 18 | ||||
| -rw-r--r-- | src/Xmobar/App/Main.hs | 13 | 
2 files changed, 16 insertions, 15 deletions
| diff --git a/src/Xmobar/App/Compile.hs b/src/Xmobar/App/Compile.hs index 0a763b4..bcb18d0 100644 --- a/src/Xmobar/App/Compile.hs +++ b/src/Xmobar/App/Compile.hs @@ -131,13 +131,13 @@ trace verb msg = when verb (liftIO $ hPutStrLn stderr msg)  --  -- 'False' is returned if there are compilation errors.  -- -recompile :: MonadIO m => String -> String -> Bool -> Bool -> m Bool -recompile dir execName force verb = liftIO $ do -    let bin  = dir </> execName -        err  = dir </> (execName ++ ".errors") -        src  = dir </> (execName ++ ".hs") -        lib  = dir </> "lib" -        script = dir </> "build" +recompile :: MonadIO m => String -> String -> String -> Bool -> Bool -> m Bool +recompile confDir dataDir execName force verb = liftIO $ do +    let bin  = confDir </> execName +        err  = dataDir </> (execName ++ ".errors") +        src  = confDir </> (execName ++ ".hs") +        lib  = confDir </> "lib" +        script = confDir </> "build"      useScript <- checkBuildScript verb script      sc <- if useScript || force            then return True @@ -149,8 +149,8 @@ recompile dir execName force verb = liftIO $ do                      \errHandle ->                        waitForProcess =<<                          if useScript -                        then runScript script bin dir errHandle -                        else runGHC bin dir errHandle +                        then runScript script bin confDir errHandle +                        else runGHC bin confDir errHandle          installSignalHandlers          if status == ExitSuccess              then trace verb "Xmobar recompilation process exited with success!" diff --git a/src/Xmobar/App/Main.hs b/src/Xmobar/App/Main.hs index e54c846..714d153 100644 --- a/src/Xmobar/App/Main.hs +++ b/src/Xmobar/App/Main.hs @@ -70,14 +70,14 @@ cleanupThreads vars =    for_ (concat vars) $ \(asyncs, _) ->      for_ asyncs cancel -buildLaunch :: Bool -> Bool -> FilePath -> ParseError -> IO () -buildLaunch verb force p e = do +buildLaunch :: Bool -> Bool -> FilePath -> String -> ParseError -> IO () +buildLaunch verb force p datadir e = do    let exec = takeBaseName p -      dir = takeDirectory p +      confDir = takeDirectory p        ext = takeExtension p    if ext `elem` [".hs", ".hsc", ".lhs"] -    then recompile dir exec force verb >> -         executeFile (dir </> exec) False [] Nothing +    then recompile confDir datadir exec force verb >> +         executeFile (confDir </> exec) False [] Nothing      else trace True ("Invalid configuration file: " ++ show e) >>           trace True "\n(No compilation attempted: \                      \only .hs, .hsc or .lhs files are compiled)" @@ -101,7 +101,8 @@ xmobarMain = do                  (c:_) -> error $ c ++ ": file not found"                  _ -> doOpts defaultConfig flags >>= xmobar      Just p -> do r <- readConfig defaultConfig p +                 dataDir <- xmobarDataDir                   case r of                     Left e -> -                     buildLaunch (verboseFlag flags) (recompileFlag flags) p e +                     buildLaunch (verboseFlag flags) (recompileFlag flags) p dataDir e                     Right (c, defs) -> doOpts c flags >>= xmobar' defs | 
