diff options
Diffstat (limited to 'src/lib/Xmobar')
-rw-r--r-- | src/lib/Xmobar/Commands.hs | 2 | ||||
-rw-r--r-- | src/lib/Xmobar/Config.hs | 16 | ||||
-rw-r--r-- | src/lib/Xmobar/Plugins.hs | 2 | ||||
-rw-r--r-- | src/lib/Xmobar/Plugins/BufferedPipeReader.hs | 1 | ||||
-rw-r--r-- | src/lib/Xmobar/Plugins/CommandReader.hs | 1 | ||||
-rw-r--r-- | src/lib/Xmobar/Plugins/MBox.hs | 2 | ||||
-rw-r--r-- | src/lib/Xmobar/Plugins/Mail.hs | 2 | ||||
-rw-r--r-- | src/lib/Xmobar/Plugins/MarqueePipeReader.hs | 3 | ||||
-rw-r--r-- | src/lib/Xmobar/Plugins/PipeReader.hs | 5 | ||||
-rw-r--r-- | src/lib/Xmobar/Plugins/StdinReader.hs | 1 | ||||
-rw-r--r-- | src/lib/Xmobar/Signal.hs | 2 | ||||
-rw-r--r-- | src/lib/Xmobar/Utils.hs (renamed from src/lib/Xmobar/Plugins/Utils.hs) | 22 | ||||
-rw-r--r-- | src/lib/Xmobar/XUtil.hs | 15 |
13 files changed, 48 insertions, 26 deletions
diff --git a/src/lib/Xmobar/Commands.hs b/src/lib/Xmobar/Commands.hs index ececdd9..9c92de0 100644 --- a/src/lib/Xmobar/Commands.hs +++ b/src/lib/Xmobar/Commands.hs @@ -32,7 +32,7 @@ import System.Exit import System.IO (hClose) import Xmobar.Signal -import Xmobar.XUtil +import Xmobar.Utils (hGetLineSafe) class Show e => Exec e where alias :: e -> String diff --git a/src/lib/Xmobar/Config.hs b/src/lib/Xmobar/Config.hs index 21b29fa..364ce17 100644 --- a/src/lib/Xmobar/Config.hs +++ b/src/lib/Xmobar/Config.hs @@ -21,8 +21,12 @@ module Xmobar.Config , XPosition (..), Align (..), Border(..) , defaultConfig , runnableTypes + , getXdgConfigFile ) where +import System.Environment +import System.Directory (getHomeDirectory) +import System.FilePath ((</>)) import Xmobar.Commands import {-# SOURCE #-} Xmobar.Runnable @@ -168,3 +172,15 @@ runnableTypes :: Command :*: Monitors :*: Date :*: PipeReader :*: #endif MarqueePipeReader :*: () runnableTypes = undefined + +xdgConfigDir :: IO String +xdgConfigDir = do env <- getEnvironment + case lookup "XDG_CONFIG_HOME" env of + Just val -> return val + Nothing -> fmap (</> ".config") getHomeDirectory + +xmobarConfigDir :: IO FilePath +xmobarConfigDir = fmap (</> "xmobar") xdgConfigDir + +getXdgConfigFile :: IO FilePath +getXdgConfigFile = fmap (</> "xmobarrc") xmobarConfigDir diff --git a/src/lib/Xmobar/Plugins.hs b/src/lib/Xmobar/Plugins.hs index e8c6403..284a9f5 100644 --- a/src/lib/Xmobar/Plugins.hs +++ b/src/lib/Xmobar/Plugins.hs @@ -17,8 +17,6 @@ module Xmobar.Plugins ( Exec (..) , tenthSeconds - , hGetLineSafe ) where import Xmobar.Commands -import Xmobar.XUtil diff --git a/src/lib/Xmobar/Plugins/BufferedPipeReader.hs b/src/lib/Xmobar/Plugins/BufferedPipeReader.hs index d4d30a1..4bb80db 100644 --- a/src/lib/Xmobar/Plugins/BufferedPipeReader.hs +++ b/src/lib/Xmobar/Plugins/BufferedPipeReader.hs @@ -23,6 +23,7 @@ import System.IO.Unsafe(unsafePerformIO) import Xmobar.Environment import Xmobar.Plugins import Xmobar.Signal +import Xmobar.Utils(hGetLineSafe) data BufferedPipeReader = BufferedPipeReader String [(Int, Bool, String)] deriving (Read, Show) diff --git a/src/lib/Xmobar/Plugins/CommandReader.hs b/src/lib/Xmobar/Plugins/CommandReader.hs index 80b6299..e90fa62 100644 --- a/src/lib/Xmobar/Plugins/CommandReader.hs +++ b/src/lib/Xmobar/Plugins/CommandReader.hs @@ -17,6 +17,7 @@ module Xmobar.Plugins.CommandReader where import System.IO import Xmobar.Plugins +import Xmobar.Utils (hGetLineSafe) import System.Process(runInteractiveCommand, getProcessExitCode) data CommandReader = CommandReader String String diff --git a/src/lib/Xmobar/Plugins/MBox.hs b/src/lib/Xmobar/Plugins/MBox.hs index 2281629..20e63cf 100644 --- a/src/lib/Xmobar/Plugins/MBox.hs +++ b/src/lib/Xmobar/Plugins/MBox.hs @@ -18,7 +18,7 @@ module Xmobar.Plugins.MBox (MBox(..)) where import Prelude import Xmobar.Plugins #ifdef INOTIFY -import Xmobar.Plugins.Utils (changeLoop, expandHome) +import Xmobar.Utils (changeLoop, expandHome) import Control.Monad (when) import Control.Concurrent.STM diff --git a/src/lib/Xmobar/Plugins/Mail.hs b/src/lib/Xmobar/Plugins/Mail.hs index c41b5b3..d8946bf 100644 --- a/src/lib/Xmobar/Plugins/Mail.hs +++ b/src/lib/Xmobar/Plugins/Mail.hs @@ -17,7 +17,7 @@ module Xmobar.Plugins.Mail where import Xmobar.Plugins #ifdef INOTIFY -import Xmobar.Plugins.Utils (expandHome, changeLoop) +import Xmobar.Utils (expandHome, changeLoop) import Control.Monad import Control.Concurrent.STM diff --git a/src/lib/Xmobar/Plugins/MarqueePipeReader.hs b/src/lib/Xmobar/Plugins/MarqueePipeReader.hs index ad6f27f..ad1ae40 100644 --- a/src/lib/Xmobar/Plugins/MarqueePipeReader.hs +++ b/src/lib/Xmobar/Plugins/MarqueePipeReader.hs @@ -16,7 +16,8 @@ module Xmobar.Plugins.MarqueePipeReader where import System.IO (openFile, IOMode(ReadWriteMode), Handle) import Xmobar.Environment -import Xmobar.Plugins (tenthSeconds, Exec(alias, start), hGetLineSafe) +import Xmobar.Plugins (tenthSeconds, Exec(alias, start)) +import Xmobar.Utils(hGetLineSafe) import System.Posix.Files (getFileStatus, isNamedPipe) import Control.Concurrent(forkIO, threadDelay) import Control.Concurrent.STM (TChan, atomically, writeTChan, tryReadTChan, newTChan) diff --git a/src/lib/Xmobar/Plugins/PipeReader.hs b/src/lib/Xmobar/Plugins/PipeReader.hs index 7166163..593a4a7 100644 --- a/src/lib/Xmobar/Plugins/PipeReader.hs +++ b/src/lib/Xmobar/Plugins/PipeReader.hs @@ -15,8 +15,9 @@ module Xmobar.Plugins.PipeReader where import System.IO -import Xmobar.Plugins -import Xmobar.Environment +import Xmobar.Plugins(Exec(..)) +import Xmobar.Environment(expandEnv) +import Xmobar.Utils(hGetLineSafe) import System.Posix.Files import Control.Concurrent(threadDelay) import Control.Exception diff --git a/src/lib/Xmobar/Plugins/StdinReader.hs b/src/lib/Xmobar/Plugins/StdinReader.hs index 372e4f9..ad8e60c 100644 --- a/src/lib/Xmobar/Plugins/StdinReader.hs +++ b/src/lib/Xmobar/Plugins/StdinReader.hs @@ -25,6 +25,7 @@ import System.IO import Control.Exception (SomeException(..), handle) import Xmobar.Plugins import Xmobar.Actions (stripActions) +import Xmobar.Utils (hGetLineSafe) data StdinReader = StdinReader | UnsafeStdinReader deriving (Read, Show) diff --git a/src/lib/Xmobar/Signal.hs b/src/lib/Xmobar/Signal.hs index bdc4be1..fd68e80 100644 --- a/src/lib/Xmobar/Signal.hs +++ b/src/lib/Xmobar/Signal.hs @@ -33,7 +33,7 @@ import DBus (IsVariant(..)) import Control.Monad ((>=>)) #endif -import Xmobar.Plugins.Utils (safeHead) +import Xmobar.Utils (safeHead) data WakeUp = WakeUp deriving (Show,Typeable) instance Exception WakeUp diff --git a/src/lib/Xmobar/Plugins/Utils.hs b/src/lib/Xmobar/Utils.hs index 6546c15..ce8c4ad 100644 --- a/src/lib/Xmobar/Plugins/Utils.hs +++ b/src/lib/Xmobar/Utils.hs @@ -1,7 +1,9 @@ +{-# LANGUAGE CPP #-} + ------------------------------------------------------------------------------ -- | --- Module: Plugins.Utils --- Copyright: (c) 2010 Jose Antonio Ortega Ruiz +-- Module: Utils +-- Copyright: (c) 2010, 2018 Jose Antonio Ortega Ruiz -- License: BSD3-style (see LICENSE) -- -- Maintainer: Jose A Ortega Ruiz <jao@gnu.org> @@ -15,18 +17,30 @@ ------------------------------------------------------------------------------ -module Xmobar.Plugins.Utils (expandHome, changeLoop, safeHead) where +module Xmobar.Utils (expandHome, changeLoop, safeHead, hGetLineSafe) where import Control.Monad import Control.Concurrent.STM import System.Environment import System.FilePath +import System.IO + +#if defined XFT || defined UTF8 +import qualified System.IO as S (hGetLine) +#endif + +hGetLineSafe :: Handle -> IO String +#if defined XFT || defined UTF8 +hGetLineSafe = S.hGetLine +#else +hGetLineSafe = hGetLine +#endif expandHome :: FilePath -> IO FilePath expandHome ('~':'/':path) = fmap (</> path) (getEnv "HOME") -expandHome p = return p +expandHome p = return p changeLoop :: Eq a => STM a -> (a -> IO ()) -> IO () changeLoop s f = atomically s >>= go diff --git a/src/lib/Xmobar/XUtil.hs b/src/lib/Xmobar/XUtil.hs index 536a2fb..c4b4531 100644 --- a/src/lib/Xmobar/XUtil.hs +++ b/src/lib/Xmobar/XUtil.hs @@ -22,7 +22,6 @@ module Xmobar.XUtil , textWidth , printString , nextEvent' - , hGetLineSafe ) where import Control.Concurrent @@ -36,26 +35,16 @@ import qualified Graphics.X11.Xlib as Xlib (textExtents, textWidth) import Graphics.X11.Xlib.Extras import System.Mem.Weak ( addFinalizer ) import System.Posix.Types (Fd(..)) -import System.IO - -#if defined XFT || defined UTF8 -import qualified System.IO as S (hGetLine) -#endif #if defined XFT import Xmobar.MinXft import Graphics.X11.Xrender +#else +import System.IO(hPutStrLn, stderr) #endif import Xmobar.ColorCache -hGetLineSafe :: Handle -> IO String -#if defined XFT || defined UTF8 -hGetLineSafe = S.hGetLine -#else -hGetLineSafe = hGetLine -#endif - -- Hide the Core Font/Xft switching here data XFont = Core FontStruct | Utf8 FontSet |