You are not logged in.
Pages: 1
Given the process ID of a graphical application, is there a way to determine (from the command line) which workspace its window is in? Or, is there a way to query workspaces to see what windows they have open, and which process IDs are associated with those windows?
Last edited by jyoung (2024-08-21 21:17:16)
Offline
wmctrl -lvp
The second field is the workspace number. "-1" means the window is stickied and appears on all workspaces. Workspace numbering starts at 0. The third field is the pid.
You can parse out information from the results of that command as needed.
Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline
wmctrl -lvp
The second field is the workspace number. "-1" means the window is stickied and appears on all workspaces. Workspace numbering starts at 0. The third field is the pid.
You can parse out information from the results of that command as needed.
While this works if the launched programs are unique, you can run into duplicate PIDs. For example, I run a couple of terminals in different workspaces, all showing the same PID from the aforementioned command:
$ wmctrl -lvp
envir_utf8: 1
0x00e00003 -1 1406 dss-endeavouros xfce4-panel
0x00e0000a -1 1406 dss-endeavouros xfce4-panel
0x02400003 0 1434 dss-endeavouros Terminal - fish [~]
0x00e00019 -1 1406 dss-endeavouros xfce4-panel
0x00e0001d -1 1406 dss-endeavouros xfce4-panel
0x00e00022 -1 1406 dss-endeavouros xfce4-panel
0x01200007 -1 1417 dss-endeavouros Desktop
0x02400026 2 1434 dss-endeavouros Terminal - fish [~]
0x02400162 2 1434 dss-endeavouros System Monitor
Even in this example, a terminal window with a different title ("System Monitor") shows the same PID as the other 2 terminals.
Offline
ToZ, that's a really powerful command! Reading the man page, it does what I was looking for and a lost more.
ajgringo619, that's a good point. In the case of your terminal, I'm guessing that launching a "new" terminal just creates a new window for an existing terminal process, yes? I've noticed a similar pattern with a lot of graphical applications. My question here is actually aimed to subverting this behavior with gedit, but only in cases where the new instance is in a separate workspace.
Offline
ToZ, that's a really powerful command! Reading the man page, it does what I was looking for and a lost more.
ajgringo619, that's a good point. In the case of your terminal, I'm guessing that launching a "new" terminal just creates a new window for an existing terminal process, yes? I've noticed a similar pattern with a lot of graphical applications. My question here is actually aimed to subverting this behavior with gedit, but only in cases where the new instance is in a separate workspace.
I haven't tried any other terminal programs, so I'm not sure if this is exclusive to Xfce. When I create new terminals with a script, I make sure that the window titles are unique so moving them between workspaces or just finding them is simple.
Offline
what if a process has no window but does have a controlling tty paired with a pty open by xfce4terminal that shows in that list. i wrote a Python script i called ws that, with no argument, outputs the current workspace number being viewed via xfce4terminal, and, with a number, switches the view to that workspace. i'm looking at adding more capability such as outputting the workspace it is in, and switching the view to itself. all this would be through xfce4terminal since it would not know how to track through other kinds of open windows, besides possibly mapping process IDs and which workspace their window is in (unless they have windows open in multiple workspaces.
and no, i have not figured out how to open a window in a workspace no currently being viewed.
Offline
Pages: 1
[ Generated in 0.010 seconds, 7 queries executed - Memory usage: 536.99 KiB (Peak: 537.84 KiB) ]