Startup Arguments

Hi, I run Xmonad on my laptop, where I sometimes have multiple displays (when I'm at my desk). As a result, I have two Xmonad configs - one for a single screen, and one for two screens, which spawns extra copies of some programs (xmobar, for example). However, to keep everything playing nice, I have to manually swap out the config each time I switch my monitor setup by editing my xmonad.hs. I tried adding code to use xrandr to detect how many screens are active, and execute the function accordingly, but this just caused my X session to break. My xinitrc script knows how many monitors are active, but I don't know how to pass that to Xmonad on startup. Is there a facility to pass arguments to Xmonad at startup from xinitrc? Or did I simply miss something in the documentation? Thanks! Chris Bell Ph.D. Student University of South Florida College of Engineering Department of Computer Science and Engineering NarMOS Research Team

On Mon, Oct 6, 2014 at 12:32 PM, Chris Bell
My xinitrc script knows how many monitors are active, but I don't know how to pass that to Xmonad on startup. Is there a facility to pass arguments to Xmonad at startup from xinitrc? Or did I simply miss something in the documentation?
Not via parameters; this has annoyed me a few times in the past, and I wonder if there is an opening here for a --user-arg parameter. In the meantime, the trick used by e.g. Fedora's default xmonad configuration is environment variables. -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

On Mon, Oct 6, 2014 at 12:53 PM, Brandon Allbery
In the meantime, the trick used by e.g. Fedora's default xmonad configuration is environment variables.
Aha, that will do nicely. Thanks! And I agree, a --user-arg param would be convenient. Regards, Chris Bell Ph.D. Student University of South Florida College of Engineering Department of Computer Science and Engineering NarMOS Research Team

Curious what code you tried. Something like this seems like it should work:
import Graphics.X11.Xinerama (getScreenInfo)
main = do
dpy <- openDisplay ""
screens <- getScreenInfo dpy
let config = case length screens of
1 -> ...
_ -> ...
xmonad config
On Mon, Oct 6, 2014 at 10:55 AM, Chris Bell
On Mon, Oct 6, 2014 at 12:53 PM, Brandon Allbery
wrote: In the meantime, the trick used by e.g. Fedora's default xmonad configuration is environment variables.
Aha, that will do nicely. Thanks! And I agree, a --user-arg param would be convenient.
Regards,
Chris Bell
Ph.D. Student University of South Florida College of Engineering Department of Computer Science and Engineering NarMOS Research Team _______________________________________________ xmonad mailing list xmonad@haskell.org http://www.haskell.org/mailman/listinfo/xmonad

On Mon, Oct 6, 2014 at 3:17 PM, Devin Mullins
Curious what code you tried
I had a nasty little shell script that called xrandr, processed the output, and returned a number indicating the number of screens. I never did figure out what made it go wrong. I didn't even know the Xinerama package existed (still new to Haskell/XMonad); I'll have to try that out. On a related note, any recommendations for resources to help me wrap my head around/understand the capabilities of Haskell? Thanks! Chris Bell Ph.D. Student University of South Florida College of Engineering Department of Computer Science and Engineering NarMOS Research Team

On Mon, Oct 6, 2014 at 2:11 PM, Chris Bell
On a related note, any recommendations for resources to help me wrap my head around/understand the capabilities of Haskell?
That's a big question. For a general intro, I've heard good things about Learn You a Haskell [1], and of course Real World Haskell [2] was co-written by one of the creators of xmonad. Myself, I just learned through my usual combination of trial-and-error and perusing blogs, mailing lists, random bits of code, and the spec. As for what your head needs wrapping around, I would need more information, but for many people the first barrier is the syntax, so... Lesson #1: function calls look like `f 1 2` instead of `f(1, 2)`. There is actually a good reason for this. Exercise: Find out what that reason is. Class dismissed. [1] http://learnyouahaskell.com/ [2] http://book.realworldhaskell.org/

On Tue, Oct 7, 2014 at 12:41 AM, Dmitri Iouchtchenko
You may have some luck with XMonad.Hooks.DynamicBars
Thanks for the suggestion! Yet another package I didn't know existed.
I don't mind having to relaunch xmonad when I switch screen layouts,
so that bug won't bother me much. I just need to discern how to
configure/implement it.
On Tue, Oct 7, 2014 at 12:49 AM, Devin Mullins
I've heard good things about Learn You a Haskell [1], and of course Real World Haskell [2]
I've been working my way through Learn You a Haskell. It's been
overwhelmingly helpful. My biggest obstacle is that I've never worked
with a pure functional language before, so most of my old paradigms
don't apply. You're probably right; picking a problem and beating my
head against it until I solve it is probably the best way.
Chris Bell
Ph.D. Student
University of South Florida
College of Engineering
Department of Computer Science and Engineering
NarMOS Research Team
Chris Bell
Ph.D. Student
University of South Florida
College of Engineering
Department of Computer Science and Engineering
NarMOS Research Team
On Tue, Oct 7, 2014 at 12:49 AM, Devin Mullins
On Mon, Oct 6, 2014 at 2:11 PM, Chris Bell
wrote: On a related note, any recommendations for resources to help me wrap my head around/understand the capabilities of Haskell?
That's a big question. For a general intro, I've heard good things about Learn You a Haskell [1], and of course Real World Haskell [2] was co-written by one of the creators of xmonad. Myself, I just learned through my usual combination of trial-and-error and perusing blogs, mailing lists, random bits of code, and the spec.
As for what your head needs wrapping around, I would need more information, but for many people the first barrier is the syntax, so... Lesson #1: function calls look like `f 1 2` instead of `f(1, 2)`. There is actually a good reason for this. Exercise: Find out what that reason is. Class dismissed.
[1] http://learnyouahaskell.com/ [2] http://book.realworldhaskell.org/

There's also XMonad.Layout.IndependentScreens.countScreens, which has the type (MonadIO m, Integral i) => m i for counting screens. I think a function like this is exposed in several other spots, too. ~d Excerpts from Devin Mullins's message of 2014-10-06 12:17:30 -0700:
Curious what code you tried. Something like this seems like it should work:
import Graphics.X11.Xinerama (getScreenInfo)
main = do dpy <- openDisplay "" screens <- getScreenInfo dpy let config = case length screens of 1 -> ... _ -> ... xmonad config
On Mon, Oct 6, 2014 at 10:55 AM, Chris Bell
wrote: On Mon, Oct 6, 2014 at 12:53 PM, Brandon Allbery
wrote: In the meantime, the trick used by e.g. Fedora's default xmonad configuration is environment variables.
Aha, that will do nicely. Thanks! And I agree, a --user-arg param would be convenient.
Regards,
Chris Bell
Ph.D. Student University of South Florida College of Engineering Department of Computer Science and Engineering NarMOS Research Team _______________________________________________ xmonad mailing list xmonad@haskell.org http://www.haskell.org/mailman/listinfo/xmonad

Chris Bell
I run Xmonad on my laptop, where I sometimes have multiple displays (when I'm at my desk). As a result, I have two Xmonad configs - one for a single screen, and one for two screens, which spawns extra copies of some programs (xmobar, for example). However, to keep everything playing nice, I have to manually swap out the config each time I switch my monitor setup by editing my xmonad.hs.
I currently work on such an addition. I use CmdArgs for the command line arguments. After that you could give a command line attribute for the base directory (e.g. --basedir=~/.xmonad-test) instead of the default (~/.xmonad) one. It is a quite small addition but i want to be backward compatible to the currently existing arguments. \= odi -- Oliver Dunkl IM: odi@jabber.ccc.de IRC: odi(irc.freenode.net)

On 06/10/2014, Chris Bell
I run Xmonad on my laptop, where I sometimes have multiple displays (when I'm at my desk). As a result, I have two Xmonad configs - one for a single screen, and one for two screens, which spawns extra copies of some programs (xmobar, for example). However, to keep everything playing nice, I have to manually swap out the config each time I switch my monitor setup by editing my xmonad.hs.
You may have some luck with XMonad.Hooks.DynamicBars (http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-DynamicBars.html). It's for dynamically starting and stopping status bars on each screen, but you could probably use it to manage other things as well. I've been using it for a while now, and it works great for having one xmobar instance per screen. There's one issue (https://code.google.com/p/xmonad/issues/detail?id=538) where the xmobars aren't dealt with automatically. There was a comment about it at the time from the maintainer (http://www.haskell.org/pipermail/xmonad/2013-June/013765.html) but I haven't heard about it since. In the meantime, I just recompile and restart xmonad using a keybinding each time I change my screen configuration, and that works. Only a single configuration file, and no need to pass in arguments or even deal with Xinerama manually.

On Tue, 7 Oct 2014 00:41:23 -0400, Dmitri Iouchtchenko
You may have some luck with XMonad.Hooks.DynamicBars (http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-DynamicBars.html). It's for dynamically starting and stopping status bars on each screen, but you could probably use it to manage other things as well. I've been using it for a while now, and it works great for having one xmobar instance per screen.
Are there any examples available of how it's used? -- Hubert Chathi - Email/Jabber: hubert@uhoreg.ca - http://www.uhoreg.ca/ PGP/GnuPG key: 4096R/113A1368 (Key available at pool.sks-keyservers.net) Fingerprint: F24C F749 6C73 DDB8 DCB8 72DE B2DE 88D3 113A 1368

[ Sorry for the necro; finally catching up on mailing lists after a long break from them. ] On Wed, 08 Oct, 2014 at 18:49:50 GMT, Hubert Chathi wrote:
Are there any examples available of how it's used?
I use it in my setup extensively. My xmonad.hs is: http://paste.fedoraproject.org/151630/62785441/ Everything related to it is from lines 515 to 566 (I won't deny that my xmonad.hs might be a little over-engineered). My xmobarrc uses the %_XMONAD_LOG% expansion which is provided by a command in the argument list (-C) to each invocation. It also uses xmonadpropwrite rather than pipes to xmobar so that xmobar can be restarted independently of xmonad. I have seen issues with instances not always starting on all the monitors, but it's very sporadic (even on my triple monitor setup at work) that I haven't taken the time to track it down. --Ben
participants (8)
-
Ben Boeckel
-
Brandon Allbery
-
Chris Bell
-
Daniel Wagner
-
Devin Mullins
-
Dmitri Iouchtchenko
-
Hubert Chathi
-
Oliver Dunkl