<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Mar 24, 2017 at 6:19 AM, Sam Halliday <span dir="ltr"><<a href="mailto:sam.halliday@gmail.com" target="_blank">sam.halliday@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Following <a href="http://stackoverflow.com/questions/10976044/" rel="noreferrer" target="_blank">http://stackoverflow.com/<wbr>questions/10976044/</a> I have added the following to my `startupHook`<br>
<br>
startup :: X ()<br>
startup = do<br>
setWMName "LG3D"<br>
spawnOn "workspace1" "urxvt"<br>
spawnOn "workspace2" "emacs"<br>
spawnOn "workspace3" "chromium"<br>
<br>
but there are three problems:<br>
<br>
1. I am duplicating the definition of my terminal. It seems like I<br>
should be using<br>
[`shellPromptOn`](<a href="http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Actions-SpawnOn.html" rel="noreferrer" target="_blank">http://<wbr>xmonad.org/xmonad-docs/xmonad-<wbr>contrib/XMonad-Actions-<wbr>SpawnOn.html</a>)<br>
but it takes an extra parameter and I don't know where to get it<br>
from.<br></blockquote><div><br></div><div>No, that's an interactive prompt at a screen edge that asks for a command, with built-in completion, and passes it to a shell. There is no terminal involved, unless that is what you tell it to launch. (The `XPConfig` is the configuration for an XMonad.Prompt screen edge popup window.)</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
2. this is putting everything on my current workspace. How can I find<br>
out what my workspaces are called? I don't believe I've customised<br>
the names, you can see [my .xmonad/xmonad.hs on github to<br>
confirm](<a href="https://github.com/fommil/dotfiles/blob/master/.xmonad/xmonad.hs" rel="noreferrer" target="_blank">https://github.com/<wbr>fommil/dotfiles/blob/master/.<wbr>xmonad/xmonad.hs</a>)<br></blockquote><div><br></div><div>You indeed haven't, so your workspaces are <font face="monospace, monospace">"1"</font>, <font face="monospace, monospace">"2"</font>, ... <font face="monospace, monospace">"9"</font>.</div><div><br></div><div>You're also missing <font face="monospace, monospace">manageSpawn</font> in the <font face="monospace, monospace">manageHook</font>, so nothing ever gets moved anyway.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">3. This will start the apps again on a `xmonad --restart`. How can we<br>
guard against that? It is very useful to be able to restart xmonad<br>
without quitting and I don't want to lose that ability.<br></blockquote><div><br></div><div>There isn't anything that combines the functionality of <font face="monospace, monospace">spawnOnce</font> and <font face="monospace, monospace">spawnOn</font> currently. I replace the <font face="monospace, monospace">spawnOnce</font> with a bit of a hack that checks whether <font face="monospace, monospace">xmonad</font> was launched with parameters (which it normally isn't, but a restart passes the old state). Using your config as a template:</div><div><br></div><div><font face="monospace, monospace"> import Control.Monad</font></div><div><font face="monospace, monospace"> import System.Environment</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"> main = do</font></div><div><font face="monospace, monospace"> args <- getArgs</font></div><div><font face="monospace, monospace"> xmonad $ ewmh $ withUrgencyHook dzenUrgencyHook { args = ["-bg", "darkgreen", "-xs", "1"] }<br></font></div></div><font face="monospace, monospace"> $ defaultConfig {</font></div><div class="gmail_extra"><font face="monospace, monospace"> terminal = "urxvt"<br> , startupHook = startup (null args)</font></div><div class="gmail_extra"><font face="monospace, monospace"> <i>-- and the rest here...</i></font></div><div class="gmail_extra"><font face="monospace, monospace"> }<br><br> startup :: Bool -> X ()<br> startup initial = do<br> setWMName "LG3D"</font></div><div class="gmail_extra"><font face="monospace, monospace"> when initial $ do<br> spawnOn "1" "urxvt"<br> spawnOn "2" "emacs"<br> spawnOn "3" "chromium"</font><br></div><div class="gmail_extra"><div><br></div><div>Note also that <font face="monospace, monospace">chromium</font> can misbehave with <font face="monospace, monospace">spawnOn</font> because we have to rely on the window registering the same associated process ID as the one we get back from running it, and it often isn't. See <a href="https://wiki.haskell.org/Xmonad/General_xmonad.hs_config_tips#Terminal_emulator_factories">https://wiki.haskell.org/Xmonad/General_xmonad.hs_config_tips#Terminal_emulator_factories</a> for more information. (<font face="monospace, monospace">chromium</font> is a bit worse in that many versions of its wrapper script fork, so the pid will <i>never</i> match.)</div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div>brandon s allbery kf8nh sine nomine associates</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a> <a href="mailto:ballbery@sinenomine.net" target="_blank">ballbery@sinenomine.net</a></div><div>unix, openafs, kerberos, infrastructure, xmonad <a href="http://sinenomine.net" target="_blank">http://sinenomine.net</a></div></div></div>
</div></div>