summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--readme.md1
-rw-r--r--src/Main.hs11
2 files changed, 12 insertions, 0 deletions
diff --git a/readme.md b/readme.md
index 89dfc1a..87d6f9a 100644
--- a/readme.md
+++ b/readme.md
@@ -394,6 +394,7 @@ xmobar --help):
-A alpha --alpha=alpha The transparency: 0 is transparent, 255 (the default) is opaque
-o --top Place xmobar at the top of the screen
-b --bottom Place xmobar at the bottom of the screen
+ -p --position=position Specify position, same as in config file
-d --dock Try to start xmobar as a dock
-a alignsep --alignsep=alignsep Separators for left, center and right text
alignment. Default: '}{'
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