Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have the following startupHook in my xmonad.hs

, startupHook = spawn "~/.xmonad/autostart"

I am starting many apps and daemons in this script and it is written to run only once on startup. But this is being run everytime I hit Mod-q, i.e., to reload and test out my changes to xmonad.hs.

I could conditionally run the programs in the autostart script but that turned out to be quite flaky. So, I was wondering if there is a way to xmonad to run this startup hook only on the initial startup and not on reloads.

I tried googling around but came up empty. Is such a thing possible?

Edit: I am running xmonad 0.11 installed from cabal on ubuntu 12.04.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

As mentionned in the FAQ, the startupHook is run each time xmonad is restarted with MOD+Q.

Also from a software point of view, it seems important that a restart is not different than a stop followed by a start. Thus there is no way to differentiate a start from a restart from within Xmonad. Hence each time Xmonad is started, it will launch the startupHook

To run programs on startup, they propose to use the usual manner by adding them to .xsession or .Xinitrc.

In your case you can just put

~/.xmonad/autostart

at the end of your .Xinitrc file.

share|improve this answer
    
Yeah, but I don't think the .Xinitrc file is run by LightDM, that is used by Ubuntu. Currently I have a line saying test -n "$(pgrep nm-applet)" && exit 0, so that if nm-applet is already running, I assume its a restart. Not a solution I'm proud of, but it works. Thank you for the answer though. –  Shrikant Sharat May 1 '13 at 11:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.