Hello,
I use XFCE and for a long time I have been employing a "launcher" script in a panel I use as a "Dock." Basically when you click a given panel item (an xfce4-panel "Launcher" item) it runs a script
launch.sh that launches the specified program (using Devilspie to specify a default workspace for the program) and then switches to that workspace. So if I want to launch Firefox, the script launches it, devilspie sees this and puts it on workspace #4, and the script switches to workspace 4 showing my fresh Firefox instance. This works pretty well, but I'd like to modify its behavior a bit.
I'd like it so that if an instance of the program is already running, instead of launching a new instance, the script will just switch the current workspace to the running instance and activate the window.
Something like this:
Code:
Click dock icon -> runs launch.sh with <appname/path> <preferred workspace> <filename/args>
if (app instance already running)
find latest instance (window?)
switch to that workspace and activate that window
else
launch the program in its default workspace and switch to that workspace
$ (how it currently functions)
I've experimented which various programs like
xdotool and
wmctl to piece together the needed pieces but have come up empty.
Something like:
- Get a list of instances of windows for program X
- Find the window ID of the latest window instance from that program
- Switch to the workspace
- Activate that window
Any ideas?