mkropat / jumpapp

A run-or-raise application switcher for any X11 desktop
MIT License
639 stars 46 forks source link

Confusing behavior / documentation #48

Closed ghost closed 5 years ago

ghost commented 5 years ago

My experience when trying to figure out how to do anything other than a basic command like jumpapp gedit was that nothing works the way i expected it to from reading the documentation. I am willing to rework the instructions & write up some useful examples for others but first i would need to understand why it works the way it does.

I'm currently using brocket (very similar concept) but always wanted to make the switch to a better maintained script. There are things i could do with brocket that i can't seem to accomplish now.

I would like to check if a window is open (by title, not by command) and if it isnt, run a command. for the sake of simplicity i will use very common programs.

wmctrl -lx output:

0x032000f8  0 gedit.Gedit computername Untitled Document 2 - gedit

i would assume that either jumpapp -t "gedit" "nautilus" or jumpapp -c "gedit" "nautilus" would recognize gedit is open, and subsequently not launch nautilus. But it always launches additional instances. Why is that?

Lupccs commented 5 years ago

I think jumpapp only looks through the windows of the application you'd want to launch

jumpapp -t title leafpad focuses the leafpad's window with "(no title)" as a title

jumpapp -t title galculator

launches galculator, cause there are no galculator windows with the word "title" in their title

ghost commented 5 years ago

Thanks! I understood it completely the wrong way. That's unfortunate, checking for titles and launching a different command seems to be impossible then. But even within the same command i can't seem to get it to work:

jumpapp -L google-chrome lists

0x024001de computername 10991 0 Google-chrome: Inbox (1) - Gmail
0x024001f8 computername 10991 0 Google-chrome: New Tab - Google Chrome

wmctrl -lx lists

0x024001c2 0 crx_kmhopmchchfpfdcdjodmpfaaphdclmlj.Google-chrome computername Inbox (2) - Gmail
0x024001f8  0 google-chrome.Google-chrome computername New Tab - Google Chrome

I want to focus the crx_kmhop... instance of chrome if open, otherwise run google-chrome (with some additional arguments i did not include here for now) None of the following did bring up the specific (not even any) chrome instance, but they always launch a new one (I tried the following):

jumpapp -t "Google" google-chrome jumpapp -t "Inbox" google-chrome jumpapp -t "Gmail" google-chrome jumpapp -t "crx" google-chrome

Although going by the documentation it is unclear if the following should work, but I tried them anyway:

jumpapp -c "Google" google-chrome jumpapp -i "Google" google-chrome

jumpapp -c "Gmail" google-chrome jumpapp -i "Gmail" google-chrome

jumpapp -c "crx" google-chrome jumpapp -i "crx" google-chrome

Did not work either. Are any of these supposed to work?

Lupccs commented 5 years ago

at the moment I'm using, as you probably already are wmctrl -xa crx_pjkljhegncpnkpknbcohdijeoejaedia || chromium-browser --profile-directory=Default --app-id=pjkljhegncpnkpknbcohdijeoejaedia anyway

jumpapp -t "Gmail" chromium-browser works for me, even though you risk to bring up every window browser that uses the word "gmail", or you risk to miss the gmail app window if some reason the "gmail" word gets lost from the title

the -c option looks for the wrong wm class, the -i option will hardly find the right chrome process

So no, the commands you mention won't work, there's already a request for an enhacement https://github.com/mkropat/jumpapp/issues/10

ghost commented 5 years ago

Many thanks for your detailed explanations, they helped me out greatly. I will keep an eye on jumpapp, but for now I will have to stay with wmctrl/brocket.

mkropat commented 5 years ago

Good feedback. Also, thanks for bringing the know-how @Lupccs.

It would be cool if jumpapp had a good way to work with Chrome profiles (right now it sucks). At the same time, I don't want to turn jumpapp into the swiss-army knife of dealing with X11 windows. That program already exists—wmctrl. Depending on what people want to do, maybe it's easier to extend wmctrl (or a similar program).

Unless convinced otherwise, I'm not inclined to merge a PR that adds support to "check for titles and launch a different command". But I would be open to an option that says "open this specific Chrome profile". Not that I'm crazy about adding program-specific logic, but I'm OK with an exception for Chrome because it is used so widely and profile switching is such a pain.

It's easy for me to discuss options cause I probably won't be making the change myself :smile: But I wanted to at least leave the option open in case someone was really motivated.

Lupccs commented 5 years ago

You're welcome, @mkropat , and thank you for your work!

I couldn't tell the difference between a chromium profile or another using xprop, so making it work could be rather difficult or tricky to implement, I suppose.

At the moment, here's the behaviour of a command like this (the gmail chromium webapp)

jumpapp -c crx_pjkljhegncpnkpknbcohdijeoejaedia chromium-browser --profile-directory=Default --app-id=pjkljhegncpnkpknbcohdijeoejaedia

If this app is the only app running, jumpapp will focus as expected, even if there is a normal chromium instance around

if there is no chromium instance running, jumpapp will launch the webapp as expected

if there is more than one webapp running, jumpapp won't load it again but will just focus on a random chromium webapp window

if there's no webapp window around, but only a normal chromium instance:

Error: found running process for 'chromium-browser', but found no window to jump to

If jumpapp could be made to look on the first field of the WM_CLASS, this would open the chance to call the focus for chrome apps, and also for the custom directory which is the method I use instead of profiles.

On xprop my gmail app (similar to all the other chrome apps) looks like this

WM_CLASS(STRING) = "crx_pjkljhegncpnkpknbcohdijeoejaedia", "Chromium-browser"

Also, if you would want to make a custom chromium webapp for calendar, xprop will show once more

WM_CLASS(STRING) = "calendar.google.com", "Chromium-browser"

Instead of a chromium profile, to differentiate, I'm using a custom directory and launching different instances of chromium like this

chromium-browser --user-data-dir=/home/lupccs/.config/chromium-us3rnam3 --profile-directory=Default

Again, xprop on that window

WM_CLASS(STRING) = "chromium-browser (/home/lupccs/.config/chromium-us3rnam3)", "Chromium-browser"