Quantcast

auto start apps on login, but not reloads

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

auto start apps on login, but not reloads

fommil
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

_______________________________________________
xmonad mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad

signature.asc (199 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: auto start apps on login, but not reloads

Brandon Allbery
On Fri, Mar 24, 2017 at 6:19 AM, Sam Halliday <[hidden email]> 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_emulator_factories 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
[hidden email]                                  [hidden email]
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net

_______________________________________________
xmonad mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: auto start apps on login, but not reloads

Yiannis Tsiouris
On 03/24, Brandon Allbery wrote:

> On Fri, Mar 24, 2017 at 6:19 AM, Sam Halliday <[hidden email]>
> 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_emulator_factories
> 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
_______________________________________________
xmonad mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: auto start apps on login, but not reloads

fommil
In reply to this post by Brandon Allbery
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 <[hidden email]> writes:

> On Fri, Mar 24, 2017 at 6:19 AM, Sam Halliday <[hidden email]>
> 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_emulator_factories
> 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
> [hidden email]                                  [hidden email]
> unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
--
Best regards,
Sam

_______________________________________________
xmonad mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad

signature.asc (199 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: auto start apps on login, but not reloads

Brandon Allbery

On Fri, Mar 24, 2017 at 12:09 PM, Sam Halliday <[hidden email]> 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
[hidden email]                                  [hidden email]
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net

_______________________________________________
xmonad mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: auto start apps on login, but not reloads

fommil
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 <[hidden email]> wrote:

>
> On Fri, Mar 24, 2017 at 12:09 PM, Sam Halliday <[hidden email]>
> 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
> [hidden email]                                  [hidden email]
> unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
_______________________________________________
xmonad mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: auto start apps on login, but not reloads

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 <[hidden email]> 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 <[hidden email]> wrote:
>>
>> On Fri, Mar 24, 2017 at 12:09 PM, Sam Halliday <[hidden email]>
>> 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
>> [hidden email]                                  [hidden email]
>> unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
> _______________________________________________
> xmonad mailing list
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad
_______________________________________________
xmonad mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: auto start apps on login, but not reloads

fommil
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 <[hidden email]> wrote:

> hi,
>
> I using for this simple :
>
>      import XMonad.Util.SpawnOnce (spawnOnce)
>      and managehook with doShift
>
>
> On 24 March 2017 at 21:43, Sam Halliday <[hidden email]> 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 <[hidden email]> wrote:
>>>
>>> On Fri, Mar 24, 2017 at 12:09 PM, Sam Halliday <[hidden email]>
>>> 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
>>> [hidden email]                                  [hidden email]
>>> unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
>> _______________________________________________
>> xmonad mailing list
>> [hidden email]
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad
_______________________________________________
xmonad mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: auto start apps on login, but not reloads

Dmitriy Matrosov
In reply to this post by fommil
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/Restartable.hs
[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

_______________________________________________
xmonad mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad
Loading...