pop-os/launcher

Match on application names rather than window names in Launcher

raxod502 opened this issue · 10 comments

Feature summary

By default, pressing Super in gnome-shell with Cosmic enabled produces a modal dialog that lets the user:

  1. Switch to an open window, by name
  2. Open an application, by name

However, for (1), the text is matched on the basis of the window title, not the application name. For example, if there is a web search for "emacs" open in Firefox, then typing in "emacs" may switch to Firefox, even if Emacs is open.

In my personal workflow, I would prefer it if the Launcher matched candidate windows based only (or at least first) on the name of the containing application (which is also displayed, underneath the window name).

How would you like it to work

I imagine that users rely on the current behavior. Therefore, one way to improve Cosmic might be to add an option for what candidates should be displayed in the Launcher. I have looked through Settings and so far I haven't been able to find any options whatsoever for Launcher behavior, although I could have missed them. By contrast, similar software for other platforms (Spotlight or Alfred on macOS) has many options regarding what can be selected from the interface, and in which order candidates are displayed.

I previously filed https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6258 because I did not realize that the behavior of gnome-shell had been changed by Cosmic. After being redirected here, I did a search of existing issues on this tracker, but did not find anything on the topic.

I am happy to prepare a pull request that either changes this behavior by default, or adds an option to customize it, if such a contribution would be acceptable.

Relevant links, screenshots, screencasts etc.

Example of where typing in "firefox" does not select Firefox by default, but rather an Emacs window that just happens to have a file called "firefox" open (I apologize for taking a photograph; it does not seem possible to use the screenshot facility while Launcher is open):

The pop-shell plugin provides search results for windows, and it is by design that it makes windows searchable via their name and title. A person may have many windows of the same application open at a given time, so a search by title narrows down the search results further. It's not too unusual to see someone using 10+ web browser windows.

I believe the algorithm currently gives a higher priority (weight) to search results whose first word matches the query, so the emacs window comes first. And the pop-shell plugin has higher priority than the desktop entries plugin, so its search results appear above.

Some things are already configurable but more will come in the future as COSMIC is developed. Some of the behaviors of plugin configuration may also change at some point to make adjustments to search result priorities more flexible.

I definitely understand the utility of matching on window names. In my personal workflow, I only ever have one window open per application at a time, which is why I am personally looking for a different behavior.

Would it be worthwhile for me to draw up a pull request to make this behavior customizable in some way?

You could give it a try

@raxod502 I've been curious about this as well. I believe this is where the priority is "hard coded" to keep open windows above all else:

https://github.com/pop-os/launcher/blob/master/service/src/lib.rs#L613

@raxod502 I have a partial solution for you that might be satisfactory, depending on if you require the launcher for app switching. In my case, I use Alt+Tab to switch between open windows, so the following solution works pretty well for me:

== Disable the pop_shell launcher plugin ==

Why?

The pop-shell plugin is responsible for finding active freedesktop environment windows (X/Wayland) and reporting them to the launcher for activation. By disabling this plugin, no active windows will be reported, and the launcher's list of action candidates will be constrained (mostly) to opening desktop applications. NOTE: This means a NEW application window will be opened every time via the launcher, even if you already have an open app of the same name.

How?

We will create a "stub" pop-shell plugin that does nothing. When the launcher activates, it will see our "stub" and preferentially load it instead of the built-in pop-shell plugin.

  1. Create a "personal variant" pop-shell plugin directory: mkdir -p ~/.local/share/pop-launcher/plugins/pop_shell/
  2. Copy the plugin.ron file from the global to your "personal variant" plugin directory: cp /usr/lib/pop-launcher/plugins/pop_shell/plugin.ron ~/.local/share/pop-launcher/plugins/pop_shell/
  3. Create a stub pop-shell binary in the same directory: touch ~/.local/share/pop-launcher/plugins/pop_shell/pop-shell && chmod +x ~/.local/share/pop-launcher/plugins/pop_shell/pop-shell

Restart your computer (or just "logout" and "login"). The pop-shell plugin should be effectively disabled.

I do want to use the launcher for app switching, personally... I will look into the Rust code you linked and see if I can adjust it and build a custom package. Thank you!

@raxod502 I've been working on a PR that will allow us to disable the match-on-window-name behavior we're seeing here. I'll try to get a WIP up soon. The gist of it, if you're interested, is to disable the first half of this condition:

            let retain = contains_pattern(&item.name, &haystack)
                || contains_pattern(&item.description, &haystack);

The item.name in this case appears to be the window name, which is the long HTML page title that sometimes gets in the way of matching on application names. AFAIU there is a deduplication step later, so it's ok to over-report matching apps if there are several windows with the same name.

I can confirm that PR #159 by @canadaduane and reviewed by @mmstick and @n3m0-22 works perfectly. Thank you so much, this is really amazing work!

In case anyone visiting this thread would like to make use of the added feature before it is yet packaged for an official release:

  • Clone the repo, follow the instructions in the README under "Packaging for a Linux distribution". Install with DESTDIR set to some local directory, call it ${pkg}. (Rust, Cargo, and Just are all available from the official repos in Pop!_OS 22.04 at least.)
  • Create a manifest file ${pkg}/DEBIAN/control with contents something like this (I based the version number on the next version number, date +%s, OS release number, and git describe, following the format of the existing apt show pop-launcher on my system):
Package: pop-launcher
Version: 1.2.2~1674270681~22.04~1fa817f
Section: utils
Priority: optional
Architecture: amd64
Maintainer: Radon Rosborough <radon@intuitiveexplanations.com>
Description: Modular IPC-based desktop launcher service
  • Build the package, fakeroot dpkg-deb --build "${pkg}" pop-launcher.deb
  • Install it, sudo apt install ./pop-launcher.deb

I'm sure I've duplicated the work of the Pop!_OS packaging team here, so if anyone happens to know where the official build scripts are located (what would be analogous to the ABS PKGBUILDs), I'd love to find out.

As it as been merged into staging master you can also use sudo apt-manage add popdev:master then sudo apt update.

To see what will be updated run apt list --upgradable after sudo apt update. If you only want this one package do the following:

  • sudo apt-manage add popdev:master
  • sudo apt update
  • sudo apt install pop-launcher
  • sudo apt-manage remove popdev-master

This will install just the pop-launcher update and you can use sudo apt upgrade normally. Correction sudo apt upgrade will also downgrade the new pop-launcher after removing popdev-master.

You can get around this by running sudo apt-mark hold pop-launcher after installing and before running sudo apt upgrade. If you do this you will need to run sudo apt-mark unhold pop-launcher when it is release.

You can also just run sudo apt update && sudo apt upgrade after sudo apt-manage add popdev:master but be aware this will install all packages in staging that have not yet been release.

Note:

If you run sudo apt full-upgrade it will also downgrade the pop-launcher update to the current(previous) version if you have not set the apt-mark hold.

If at any point you wish to revert the changes run sudo apt-mark unhold pop-launcher if you have added the hold. Then make sure popdev-master is removed. You can check this by running apt-manage to see a list. If it is not in there then run sudo apt full-upgrade. If it is there then run sudo apt-manage remove popdev-master. After that all packages installed from staging master will be downgraded to their current version after running sudo apt full-upgrade.

Wow, that's really cool @n3m0-22 ! I didn't know master had a full package source (not sure if that's the right term). Thanks for sharing.