5

Probably the reason I can not find it on the web might be that it is so obvious, but I still can not figure it out:

How can I configure XFCE so that a specific program window always automatically opens on the (e.g.) second virtual desktop?

Jaleks
  • 2,499
  • 1
  • 17
  • 34

2 Answers2

5

I'm not sure if you can start it in the other workspace, but you can move it there with a script.

Have a look at this page: https://wiki.xfce.org/faq, at the subitem "How do I programmatically switch workspaces, move windows, etc?"

So you could start your program with a simple shell script like:

#!/bin/sh
yourprogram &
PID="$!"
#echo $PID
sleep 1s 
#sleep is required because the window takes some time to open, maybe it can be adjusted
WINH="$(wmctrl -l -p | grep "$PID" | cut -d " " -f1)"
#echo $WINH
wmctrl -i -r $WINH -t 2

Its not ideal as the process may have multiple windows (no idea what would happen then), but it should work for simple programs.

rudib
  • 1,532
  • 1
  • 13
  • 33
  • Thx! I refactored it into a gist, feedback welcome: https://gist.github.com/tokland/834f9d5dd261bb2d1b3725df705619cd – tokland Dec 09 '20 at 20:06
3

Most window managers don't offer this functionality. You can run Devil's Pie to perform actions when a window is created, such as sending that window to another workspace. With Devil's Pie 1, create a file ~/.devilspie/myprogram.ds containing something like

(if (and (is (application_name) "specific-program")
         (matches (window_name) "^Program main window:"))
  (set_workspace 2))

With Devil's Pie 2, create a file ~/.devilspie2/myprogram.ds containing something like

if (get_application_name() == "specific-program" and
    string.strfind(get_window_name(), "Program main window") == 1) then
  set_workspace(2);
end
Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175