jumpapp
jumpapp copied to clipboard
Suggestion - option or function for a very specific window
Hi everybody! I'm an everyday jumpapp user but - lately - I have been in need of something that this little app couldn't do: calling for a very specific window, difficult to distinguish from others I often need to use two different Chromium profiles at the same time: in that case class, process name and such were identical while window title would change according to the website. So I thought a bit about it and came out with this little command that, for now, seems to solve the problem
sh -c "xdotool windowactivate $(cat ~/.cache/identifier) || chromium-browser --profile-directory="U53r1" & xdotool search --sync --name u53r1 > ~/.cache/identifier"
where
xdotool search --all --onlyvisible --sync --name u53r1
finds a window with the string "u53r1" in the title (I picked an odd string because "user1" could have been easily found in another window) and grabs an X window identifier, an 8 digit number that - as far as I could try - doesn't change while I switch and close tabs, as long as that Chromium instance stays open. The Chromium profile I launched opens on an homepage where I made sure "U53r1" was in the title.
That identifier gets written in a file and everytime I launch that shortcut xdotool tries to activate a window with that identifier. If it's not valid anymore it means that window has been closed, so it launches a new instance and grabs a new identifier.
I've never tried bash scripting so I made my way through mistakes and it may be a very rough solution: it works for now but do you think it will keep working? Any way I could make it better? Weaknesses? If you find it interesting you could add a similar function in jumpapp and I'll be glad I've been useful. You could of course obtain the same result with
wmctrl -l | grep 'U53r1' | grep -Eo '0x[0-9a-f]+'
and
wmctrl -ia
using an identifier related to PID - given that the PID won't change through the session - but xdotool seemed more readable to me.
Anyway, thanks for your time and for your work!
I actually evolved in this script, it didn't seem to work with just a command
#!/bin/sh
if ! $(xdotool windowactivate --sync "$(cat ~/.cache/u53r1)"); then
chromium-browser --profile-directory="U53r1" & xdotool search --all --onlyvisible --sync --name u53r1 > ~/.cache/u53r1;
fi
Of course it won't work if Chromium gets launched by the system
That last one soon didn't work out, but I solved the problem with
wmctrl -xa us3rnam3 || chromium-browser --user-data-dir=/home/lupccs/.config/chromium-us3rnam3 --profile-directory=Default
Which works fine
xprop on that window
WM_CLASS(STRING) = "chromium-browser (/home/lupccs/.config/chromium-us3rnam3)", "Chromium-browser"