Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: How to launch an application on a chosen workspace?

  1. #1
    Join Date
    Dec 2008
    Beans
    52

    How to launch an application on a chosen workspace?

    I have a multi-workspace setup, with the "workspace switcher" gadget in a corner of the screen that lets me select one of six (3x2) workspaces.

    I would like to be able to launch specific applications in specific desktops (eg from scripts), e.g.

    firefox --workspace 0 1
    evince --workspace 0 2

    or

    launch-in-workspace 0 1 firefox
    launch-in-workspace 0 2 evince


    (or whatever). Is anything like that possible?

    The closest I found was the CompizConfig Settings Manager, as specified in this thread: http://ubuntuforums.org/showthread.php?t=844385

    That allows me to say, for example, that Firefox should ALWAYS appear on workspace 0 1 and evince on 0 2, which is subtly different. For example, if I subsequently double-click to open a pdf in any other workspace, then the pdf window opens in the designated evince workspace instead of where I am (and want it).

    So I don't want a global configuration to say "the windows of this application shall always go in that workspace". Instead I would like a command-line option, or a wrapper, that lets me say where to put the application I'm launching, for THIS invocation and not globally, so that I could do for example

    launch-in-workspace 0 1 evince document1.pdf
    launch-in-workspace 1 1 evince document2.pdf

    Is this possible? How?

    Thanks

  2. #2
    Join Date
    Feb 2009
    Location
    London, UK
    Beans
    156
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: How to launch an application on a chosen workspace?

    I thought I saw something like this asked before. I'm new and ddoubt I can help but just for clarity:

    You don't want all instances of a particular app to open in one set workspace.

    Rather,

    You want an options box each time you open an app (or all apps) that asks which workspace you want it to open in.

    Is that right?

  3. #3
    Join Date
    Dec 2008
    Beans
    52

    Re: How to launch an application on a chosen workspace?

    Quote Originally Posted by Scubdup View Post
    I thought I saw something like this asked before. I'm new and ddoubt I can help but just for clarity:

    You don't want all instances of a particular app to open in one set workspace.
    Correct.

    Rather,

    You want an options box each time you open an app (or all apps) that asks which workspace you want it to open in.

    Is that right?
    No, sorry for being unclear. I definitely DON'T want an INTERACTIVE dialog box asking me each time! Rather, I want something I can use from a command-line script.

    When I launch an app the clickety-click way, I just want it to appear in the workspace I'm in.

    From a script, however, I want to be able to say: and now open these half dozen apps, putting this one here, that one there, that one over there etc etc. And I want to be able to write different scripts that put the various applications in different places, as needed, WITHOUT this constraining the positions of the applications when I invoke them interactively.

    Thanks for helping me clarify. Let me know if it makes more sense now.

  4. #4
    Join Date
    Nov 2008
    Beans
    92

    Re: How to launch an application on a chosen workspace?

    for your script you can use wmctrl

  5. #5
    Join Date
    Feb 2009
    Location
    London, UK
    Beans
    156
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: How to launch an application on a chosen workspace?

    Quote Originally Posted by ub40d View Post
    From a script, however, I want to be able to say: and now open these half dozen apps, putting this one here, that one there, that one over there etc etc. And I want to be able to write different scripts that put the various applications in different places, as needed.
    Ah, I see. So without changing anything else, you want a script that opens a particular set of apps in a particular set of windows, say, for eg Load Firefox in workspace 1, Rhythmbox in Workspace 2 playing tune X, and Deluge in workspace 3.

    There's prolly a simpler way but bblaunch sounds like it might work...

    EDIT: Scratch that, zhocchao's recommendation wmctrl looks better supported.

  6. #6
    Join Date
    Dec 2008
    Beans
    52

    Re: How to launch an application on a chosen workspace?

    Quote Originally Posted by zhocchao View Post
    for your script you can use wmctrl
    Thanks for this suggestion! After a bit of a struggle I finally got it to work (mostly).

    Main problem was that the man page has a nice-looking -t option (send window to specified desktop) but it didn't do what I expected because I wanted to send to another WORKSPACE, not to another desktop.

    I finally figured I have only one DESKTOP with six workspaces on it, as indicated by:

    wmctrl -d
    0 * DG: 7680x3200 VP: 0,0 WA: 0,25 2560x1550 N/A

    Once I got that, I realized that I couldn't just say "send to workspace n" but I had to compute the new coordinates myself and then change the window's geometry offset. And yes, this works:

    Send thunderbird to workspace 0,1:
    wmctrl -r thunderbird -e 0,2560,0,-1,-1

    Send it to 1,2:
    wmctrl -r thunderbird -e 0,5120,1600,-1,-1


    So thanks a lot for the tip and I hope the examples above are of help to the next guy with the same problem.

    Now the remaining problem I have is that this stuff only works after the window exists. So if my script does

    thunderbird
    wmctrl -r thunderbird -e 0,5120,1600,-1,-1

    then what actually happens is that thunderbird is launched, then the second statement is executed before the thunderbird window exists (and therefore it fails), and then the window appears, in the wrong place of course.

    Is there a way to tell wmctrl to wait for that window to appear?

  7. #7
    Join Date
    Nov 2008
    Beans
    92

    Re: How to launch an application on a chosen workspace?

    use sleep in your script

  8. #8
    Join Date
    Dec 2008
    Beans
    52

    Re: How to launch an application on a chosen workspace?

    Hmmm... you know that's not what I meant I hope... how can I tell when the window has finally appeared? (so that I can stop sleeping)

    For now I'm trying with a mix of wmctrl -l and fgrepping the output, but that's a bit disgusting.

  9. #9

    Re: How to launch an application on a chosen workspace?

    zhocchao

    Thanks for the info on wmcrtl. I asked about this in release 8.04, and again in 8.10, but didn't get any response. Now I know how to do it.

    My interest is in adding scripts to start up so that certain workspaces are automatically pre-populated with selected applications when the system boots up. wmcrtl with a short sleep seems to do exactly what I wanted.

    ub40d

    Thanks for raising this question again. I had given up on ever finding the answer.

    Arv
    _._
    POSIX

  10. #10
    Join Date
    Sep 2011
    Beans
    3

    Re: How to launch an application on a chosen workspace?

    I know it's been more than 2 yrs since anyone replied on this post and all, but I found this post to be quite helpful and to (sort of) return the favor: @ub40d maybe this might help http://www.foosel.org/linux/devilspie (if you're still interested that is)..

    Thanks
    Piyush

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •