
Hi all, I am trying to set up auto start of my main applications. Following http://stackoverflow.com/questions/10976044/ I have added the following to my `startupHook` startup :: X () startup = do setWMName "LG3D" spawnOn "workspace1" "urxvt" spawnOn "workspace2" "emacs" spawnOn "workspace3" "chromium" but there are three problems: 1. I am duplicating the definition of my terminal. It seems like I should be using [`shellPromptOn`](http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Actions-SpawnOn.html) but it takes an extra parameter and I don't know where to get it from. 2. this is putting everything on my current workspace. How can I find out what my workspaces are called? I don't believe I've customised the names, you can see [my .xmonad/xmonad.hs on github to confirm](https://github.com/fommil/dotfiles/blob/master/.xmonad/xmonad.hs) 3. This will start the apps again on a `xmonad --restart`. How can we guard against that? It is very useful to be able to restart xmonad without quitting and I don't want to lose that ability. NOTE: re-post of tumbleweed http://stackoverflow.com/questions/42467774 -- Best regards, Sam

On Fri, Mar 24, 2017 at 6:19 AM, Sam Halliday
Following http://stackoverflow.com/questions/10976044/ I have added the following to my `startupHook`
startup :: X () startup = do setWMName "LG3D" spawnOn "workspace1" "urxvt" spawnOn "workspace2" "emacs" spawnOn "workspace3" "chromium"
but there are three problems:
1. I am duplicating the definition of my terminal. It seems like I should be using [`shellPromptOn`](http://xmonad.org/xmonad-docs/xmonad- contrib/XMonad-Actions-SpawnOn.html) but it takes an extra parameter and I don't know where to get it from.
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.) 2. this is putting everything on my current workspace. How can I find
out what my workspaces are called? I don't believe I've customised the names, you can see [my .xmonad/xmonad.hs on github to confirm](https://github.com/fommil/dotfiles/blob/master/. xmonad/xmonad.hs)
You indeed haven't, so your workspaces are "1", "2", ... "9". You're also missing manageSpawn in the manageHook, so nothing ever gets moved anyway. 3. This will start the apps again on a `xmonad --restart`. How can we
guard against that? It is very useful to be able to restart xmonad without quitting and I don't want to lose that ability.
There isn't anything that combines the functionality of spawnOnce and spawnOn currently. I replace the spawnOnce with a bit of a hack that checks whether xmonad was launched with parameters (which it normally isn't, but a restart passes the old state). Using your config as a template: import Control.Monad import System.Environment main = do args <- getArgs xmonad $ ewmh $ withUrgencyHook dzenUrgencyHook { args = ["-bg", "darkgreen", "-xs", "1"] } $ defaultConfig { terminal = "urxvt" , startupHook = startup (null args) *-- and the rest here...* } startup :: Bool -> X () startup initial = do setWMName "LG3D" when initial $ do spawnOn "1" "urxvt" spawnOn "2" "emacs" spawnOn "3" "chromium" Note also that chromium can misbehave with spawnOn 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 https://wiki.haskell.org/Xmonad/General_xmonad.hs_config_tips#Terminal_emula... for more information. (chromium is a bit worse in that many versions of its wrapper script fork, so the pid will *never* match.) -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

On 03/24, Brandon Allbery wrote:
On Fri, Mar 24, 2017 at 6:19 AM, Sam Halliday
wrote: Following http://stackoverflow.com/questions/10976044/ I have added the following to my `startupHook`
startup :: X () startup = do setWMName "LG3D" spawnOn "workspace1" "urxvt" spawnOn "workspace2" "emacs" spawnOn "workspace3" "chromium"
but there are three problems:
1. I am duplicating the definition of my terminal. It seems like I should be using [`shellPromptOn`](http://xmonad.org/xmonad-docs/xmonad- contrib/XMonad-Actions-SpawnOn.html) but it takes an extra parameter and I don't know where to get it from.
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.)
2. this is putting everything on my current workspace. How can I find
out what my workspaces are called? I don't believe I've customised the names, you can see [my .xmonad/xmonad.hs on github to confirm](https://github.com/fommil/dotfiles/blob/master/. xmonad/xmonad.hs)
You indeed haven't, so your workspaces are "1", "2", ... "9".
You're also missing manageSpawn in the manageHook, so nothing ever gets moved anyway.
3. This will start the apps again on a `xmonad --restart`. How can we
guard against that? It is very useful to be able to restart xmonad without quitting and I don't want to lose that ability.
There isn't anything that combines the functionality of spawnOnce and spawnOn currently. I replace the spawnOnce with a bit of a hack that checks whether xmonad was launched with parameters (which it normally isn't, but a restart passes the old state). Using your config as a template:
import Control.Monad import System.Environment
main = do args <- getArgs xmonad $ ewmh $ withUrgencyHook dzenUrgencyHook { args = ["-bg", "darkgreen", "-xs", "1"] } $ defaultConfig { terminal = "urxvt" , startupHook = startup (null args) *-- and the rest here...* }
startup :: Bool -> X () startup initial = do setWMName "LG3D" when initial $ do spawnOn "1" "urxvt" spawnOn "2" "emacs" spawnOn "3" "chromium"
Note also that chromium can misbehave with spawnOn 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 https://wiki.haskell.org/Xmonad/General_xmonad.hs_config_tips#Terminal_emula... for more information. (chromium is a bit worse in that many versions of its wrapper script fork, so the pid will *never* match.)
Oh, this is actually very useful! :] Thanks to Brandon for sharing your solution and to Sam for starting the thread! Cheers, Yiannis

Thanks Brandon!
I've updated my config
https://github.com/fommil/dotfiles/blob/master/xmonad/xmonad.hs
and now my three apps startup on the correct workspaces! No apparent
issues with chromium.
Unfortunately, this doesn't seem to have fixed the --reload problem, so
I guess args is always coming up non-null?
Brandon Allbery
On Fri, Mar 24, 2017 at 6:19 AM, Sam Halliday
wrote: Following http://stackoverflow.com/questions/10976044/ I have added the following to my `startupHook`
startup :: X () startup = do setWMName "LG3D" spawnOn "workspace1" "urxvt" spawnOn "workspace2" "emacs" spawnOn "workspace3" "chromium"
but there are three problems:
1. I am duplicating the definition of my terminal. It seems like I should be using [`shellPromptOn`](http://xmonad.org/xmonad-docs/xmonad- contrib/XMonad-Actions-SpawnOn.html) but it takes an extra parameter and I don't know where to get it from.
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.)
2. this is putting everything on my current workspace. How can I find
out what my workspaces are called? I don't believe I've customised the names, you can see [my .xmonad/xmonad.hs on github to confirm](https://github.com/fommil/dotfiles/blob/master/. xmonad/xmonad.hs)
You indeed haven't, so your workspaces are "1", "2", ... "9".
You're also missing manageSpawn in the manageHook, so nothing ever gets moved anyway.
3. This will start the apps again on a `xmonad --restart`. How can we
guard against that? It is very useful to be able to restart xmonad without quitting and I don't want to lose that ability.
There isn't anything that combines the functionality of spawnOnce and spawnOn currently. I replace the spawnOnce with a bit of a hack that checks whether xmonad was launched with parameters (which it normally isn't, but a restart passes the old state). Using your config as a template:
import Control.Monad import System.Environment
main = do args <- getArgs xmonad $ ewmh $ withUrgencyHook dzenUrgencyHook { args = ["-bg", "darkgreen", "-xs", "1"] } $ defaultConfig { terminal = "urxvt" , startupHook = startup (null args) *-- and the rest here...* }
startup :: Bool -> X () startup initial = do setWMName "LG3D" when initial $ do spawnOn "1" "urxvt" spawnOn "2" "emacs" spawnOn "3" "chromium"
Note also that chromium can misbehave with spawnOn 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 https://wiki.haskell.org/Xmonad/General_xmonad.hs_config_tips#Terminal_emula... for more information. (chromium is a bit worse in that many versions of its wrapper script fork, so the pid will *never* match.)
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-- Best regards, Sam

On Fri, Mar 24, 2017 at 12:09 PM, Sam Halliday
Thanks Brandon!
I've updated my config
https://github.com/fommil/dotfiles/blob/master/xmonad/xmonad.hs
and now my three apps startup on the correct workspaces! No apparent issues with chromium.
Unfortunately, this doesn't seem to have fixed the --reload problem, so I guess args is always coming up non-null?
Hm? Did it restart them inappropriately, or did it not start them at all? The recent changes to use a state file are buggy and cause some rather bizarre problems. But there's also the question of compatibility with older versions; I was reassured that the change *is* backward compatible, but if you aren't seeing parameters from a restart then either that or some other change is not backward compatible. (I've already had to rewire this once because of an unannounced non-backward-compatible change leading up to 0.12. I am not a fan of "move fast, break stuff" especially if the only way I can find out about it is to audit every single commit.) -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

Hi Brandon,
When I did an `xmonad --restart` it started all the apps again...
which is exactly the opposite of what I wanted. I only want the apps
to start on initial startup.
Just thinking aloud, another way I could do this would be to have
rules in place that always assign a new app to a given workspace. Then
I could start my main apps as usual from .xsession. But sometimes I
move a chromium window to a different workspace, so it would need to
allow that.
BTW, I'm using xmonad from ArchLinux 0.13. Should I be using a dev version?
On 24 March 2017 at 19:53, Brandon Allbery
On Fri, Mar 24, 2017 at 12:09 PM, Sam Halliday
wrote: Thanks Brandon!
I've updated my config
https://github.com/fommil/dotfiles/blob/master/xmonad/xmonad.hs
and now my three apps startup on the correct workspaces! No apparent issues with chromium.
Unfortunately, this doesn't seem to have fixed the --reload problem, so I guess args is always coming up non-null?
Hm? Did it restart them inappropriately, or did it not start them at all?
The recent changes to use a state file are buggy and cause some rather bizarre problems. But there's also the question of compatibility with older versions; I was reassured that the change *is* backward compatible, but if you aren't seeing parameters from a restart then either that or some other change is not backward compatible. (I've already had to rewire this once because of an unannounced non-backward-compatible change leading up to 0.12. I am not a fan of "move fast, break stuff" especially if the only way I can find out about it is to audit every single commit.)
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

hi,
I using for this simple :
import XMonad.Util.SpawnOnce (spawnOnce)
and managehook with doShift
On 24 March 2017 at 21:43, Sam Halliday
Hi Brandon,
When I did an `xmonad --restart` it started all the apps again... which is exactly the opposite of what I wanted. I only want the apps to start on initial startup.
Just thinking aloud, another way I could do this would be to have rules in place that always assign a new app to a given workspace. Then I could start my main apps as usual from .xsession. But sometimes I move a chromium window to a different workspace, so it would need to allow that.
BTW, I'm using xmonad from ArchLinux 0.13. Should I be using a dev version?
On 24 March 2017 at 19:53, Brandon Allbery
wrote: On Fri, Mar 24, 2017 at 12:09 PM, Sam Halliday
wrote: Thanks Brandon!
I've updated my config
https://github.com/fommil/dotfiles/blob/master/xmonad/xmonad.hs
and now my three apps startup on the correct workspaces! No apparent issues with chromium.
Unfortunately, this doesn't seem to have fixed the --reload problem, so I guess args is always coming up non-null?
Hm? Did it restart them inappropriately, or did it not start them at all?
The recent changes to use a state file are buggy and cause some rather bizarre problems. But there's also the question of compatibility with older versions; I was reassured that the change *is* backward compatible, but if you aren't seeing parameters from a restart then either that or some other change is not backward compatible. (I've already had to rewire this once because of an unannounced non-backward-compatible change leading up to 0.12. I am not a fan of "move fast, break stuff" especially if the only way I can find out about it is to audit every single commit.)
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
_______________________________________________ xmonad mailing list xmonad@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad

Thanks Ondrej,
Do you have a fuller example of how you did that? I get lost in the Haskell.
On 24 March 2017 at 22:02, Ondřej Súkup
hi,
I using for this simple :
import XMonad.Util.SpawnOnce (spawnOnce) and managehook with doShift
On 24 March 2017 at 21:43, Sam Halliday
wrote: Hi Brandon,
When I did an `xmonad --restart` it started all the apps again... which is exactly the opposite of what I wanted. I only want the apps to start on initial startup.
Just thinking aloud, another way I could do this would be to have rules in place that always assign a new app to a given workspace. Then I could start my main apps as usual from .xsession. But sometimes I move a chromium window to a different workspace, so it would need to allow that.
BTW, I'm using xmonad from ArchLinux 0.13. Should I be using a dev version?
On 24 March 2017 at 19:53, Brandon Allbery
wrote: On Fri, Mar 24, 2017 at 12:09 PM, Sam Halliday
wrote: Thanks Brandon!
I've updated my config
https://github.com/fommil/dotfiles/blob/master/xmonad/xmonad.hs
and now my three apps startup on the correct workspaces! No apparent issues with chromium.
Unfortunately, this doesn't seem to have fixed the --reload problem, so I guess args is always coming up non-null?
Hm? Did it restart them inappropriately, or did it not start them at all?
The recent changes to use a state file are buggy and cause some rather bizarre problems. But there's also the question of compatibility with older versions; I was reassured that the change *is* backward compatible, but if you aren't seeing parameters from a restart then either that or some other change is not backward compatible. (I've already had to rewire this once because of an unannounced non-backward-compatible change leading up to 0.12. I am not a fan of "move fast, break stuff" especially if the only way I can find out about it is to audit every single commit.)
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
_______________________________________________ xmonad mailing list xmonad@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad

On 03/24/2017 11:43 PM, Sam Halliday wrote:
[..] Just thinking aloud, another way I could do this would be to have rules in place that always assign a new app to a given workspace. Then I could start my main apps as usual from .xsession. But sometimes I move a chromium window to a different workspace, so it would need to allow that.
Hi. Some time ago i've written a [module for tracking PIDs][1] of launched programs and not launching them again, if process still running. But.. - It was not released yet, because i think about rewriting (part of) it. - It depends on other modules from my config. Not that many and not really big, but still.. - I don't know (and heven't tried) how to build a config with this module alone (perhaps, place it in `.xmonad/lib` directory?). Now i build using `stack` and rebuild work through [X.H.EntryHelper][4]. I've heard, that xmonad 0.13 supports different build systems, but i haven't tried. - Part of this module (related to docks, not needed in your config) is broken with `xmonad-contrib-0.13` (the struts are no longer honored and panels are covered by windows). - Program pid tracking will move *all* new windows of a multi-window application to defined workspace. That may be not convenient at all in some cases: e.g. you want to start a new browser window on another workspace, but the new window will still appear on a workspace assigned to it. The same applies to a windows, like password manager prompts, etc. But, that's said, it still works with `xmonad-0.12` and stack will install all necessary dependencies for you. [Here][2] is your config, which starts programs using my module `Sgf.XMonad.Restartable` and the listed programs do not restart after `xmonad --restart`, if they're still running. To build your config i replaced mine (`src/xmonad.hs`) in [my repository][3] and installed it with `make install`. **NOTE** : `make install` will also install `xmobarrc`, `Xsession` and other stuff. You may either try `make install_xmonad` or (better) create a new user for trying this. [1]: https://github.com/sgf-dma/sgf-xmonad-modules/blob/master/src/Sgf/XMonad/Res... [2]: https://gist.github.com/sgf-dma/2709f8279365b262f567d3d99f43dfc1 [3]: https://github.com/sgf-dma/sgf-xmonad-config [4]: https://hackage.haskell.org/package/xmonad-entryhelper
participants (5)
-
Brandon Allbery
-
Dmitriy Matrosov
-
Ondřej Súkup
-
Sam Halliday
-
Yiannis Tsiouris