How do you get the process id of a window started with qvm-run?

I like to multitask with qubes. My workflow involves launching a program on a qube, switching workspaces, launching another program from a different qube, etc. However, I want to keep each program to stay in the workspace it was launched in rather than the current active workspace.

I’m thinking of using xdotool to move windows to the workspace they originated from. To do this, I’m thinking of searching by pid to get a window number and then running xdotool to move the window.

xdotool search --pid {pid}
xdotool set_desktop_for_window {window_number} {desktop}

How can I get the process id for windows started with qvm-run?

I have another workaround at the moment. I use wmctrl -s instead of xdotool to switch to desired workspace, then launch the program. I discussed it here:

wmctrl -s lets me change workspaces and launch a program, but the problem’s that I need to wait until the program launches. If I switch to another workspace manually, the program will run in that workspace instead.

Would devilspie2 perhaps be an option?

I did read about devilspie2 when I was looking for a solution, but I was hoping to avoid installing programs to dom0.

I have been working on developing tools for similar purposes (not sure if you saw that thread I shared before). Getting PID from subprocess Python object is possible. But you should know Python and could read the source. I did not have the time to focus on sending programs to desired workspace aspect of my project. Hopefully in near future.

I did read through your project and it sounds like something very similar to what I want as well. It’s something that I’ll be following.

That’s great that we can get the PID. Where can I find the source file?

1 Like

It is a part of qubes-core-admin-client repository. It should be installed at /usr/lib/python3.11/site-packages/qubesadmin/tools/