summaryrefslogtreecommitdiffhomepage
path: root/src/Main.hs
diff options
context:
space:
mode:
authorValentin Shirokov <regellosigkeitsaxiom@users.noreply.github.com>2015-12-31 02:04:40 +0800
committerjao <jao@gnu.org>2015-12-31 01:00:03 +0100
commiteeb62efa3e8a8f802d4afecc9e4dadc1911a3271 (patch)
tree538dc20a8887e219a523acea613edd783658d416 /src/Main.hs
parent9077c73f9a73c86bd9cba2b526aea198e22727aa (diff)
downloadxmobar-eeb62efa3e8a8f802d4afecc9e4dadc1911a3271.tar.gz
xmobar-eeb62efa3e8a8f802d4afecc9e4dadc1911a3271.tar.bz2
Added "-p" launch option
`-p "string"` will override position settings set in configuration file. Useful for launching multiple xmobars from single configuration file, which is almost necessary when using non-monospace fonts.
Diffstat (limited to 'src/Main.hs')
-rw-r--r--src/Main.hs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/Main.hs b/src/Main.hs
index 209eee1..0596600 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -38,6 +38,7 @@ import System.Environment
import System.FilePath ((</>))
import System.Posix.Files
import Control.Monad (unless, liftM)
+import Text.Read (readMaybe)
import Signal (setupSignalHandler)
@@ -133,6 +134,7 @@ data Opts = Help
| Template String
| OnScr String
| IconRoot String
+ | Position String
deriving Show
options :: [OptDescr Opts]
@@ -166,6 +168,8 @@ options =
"Add to the list of commands to be executed"
, Option "x" ["screen"] (ReqArg OnScr "screen")
"On which X screen number to start"
+ , Option "p" ["position"] (ReqArg Position "position")
+ "Specify position of xmobar. Same syntax as in config file"
]
getOpts :: [String] -> IO ([Opts], [String])
@@ -219,6 +223,7 @@ doOpts conf (o:oo) =
AddCommand s -> case readCom 'C' s of
Right x -> doOpts' (conf {commands = commands conf ++ x})
Left e -> putStr (e ++ usage) >> exitWith (ExitFailure 1)
+ Position s -> readPosition s
where readCom c str =
case readStr str of
[x] -> Right x
@@ -226,3 +231,9 @@ doOpts conf (o:oo) =
"specified with the -" ++ c:" option\n")
readStr str = [x | (x,t) <- reads str, ("","") <- lex t]
doOpts' opts = doOpts opts oo
+ readPosition string =
+ case readMaybe string of
+ Just x -> doOpts' (conf { position = x })
+ Nothing -> do
+ putStrLn "Can't parse position option, ignoring"
+ doOpts' conf