Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion - option or function for a very specific window #36

Open
Lupccs opened this issue Aug 15, 2018 · 2 comments
Open

Suggestion - option or function for a very specific window #36

Lupccs opened this issue Aug 15, 2018 · 2 comments

Comments

@Lupccs
Copy link

Lupccs commented Aug 15, 2018

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!

@Lupccs
Copy link
Author

Lupccs commented Aug 16, 2018

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

@Lupccs
Copy link
Author

Lupccs commented Jun 21, 2019

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant