The goal was to make chromium desktop icon, that was created for a second profile, appear in the Dash and the app switcher (alt+tab) as an independent app icon. I gave that .desktop
a StartupWMClass
entry and added a --class
flag as suggested here, but the problem remained because I believe that chromium changes the wm class name to the default one after the launch.
Tried to fiddle with some code via looking glass, but no success there.
For reference, I used the following functions:
imports.gi.Shell.AppSystem.get_default() // Shell.AppSystem (https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/src/shell-app-system.c)
imports.gi.Shell.AppSystem.get_default().get_running() // [ Shell.App ] (https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/src/shell-app.c)
imports.gi.Shell.AppSystem.get_default().get_running()[0].appInfo // Gio.DesktopAppInfo (https://docs.gtk.org/gio/class.DesktopAppInfo.html)
imports.gi.Shell.AppSystem.get_default().get_running()[0].appInfo.get_filename()
imports.gi.Shell.AppSystem.get_default().get_installed() // [ Shell.App ]
imports.gi.Shell.AppSystem.get_default().get_installed()[0].get_filename()
I also created an extension just to make sure I can monkeypatch the get_running()
function and that the system will use the modified function. I made an extension that make the function always return an empty array, but only the Dash in the Overview updated and showed that all the apps are not running. The app switcher (alt+tab) still showed the running apps as usual.
extension.js
:
/* exported init */
let original;
class Extension {
constructor() {}
enable() {
original = imports.gi.Shell.AppSystem.prototype.get_running;
imports.gi.Shell.AppSystem.prototype.get_running = () => [];
}
disable() {
imports.gi.Shell.AppSystem.prototype.get_running = original;
}
}
function init() {
return new Extension();
}
The following code change the window's name and icon of a running Chromium, but it takes effect after a few minutes, and only then new windows will get the original name and icon:
const runningApps = imports.gi.Shell.AppSystem.get_default().get_running().filter(a => a.get_windows().find(w => w.wm_class === 'Chromium-freeworld')); // find running windows of Chromium
runningApps[0].get_name = () => 'my name'; // change the title
runningApps[0].get_icon().prepend_name('org.gnome.Cheese'); // change the icon
The name change apply if we re-focus on the window.
Extensions development: https://gjs.guide/extensions/
Gnome Shell Docs: https://gjs-docs.gnome.org/shell01~0.1_api/
Reddit: https://www.reddit.com/r/gnome/?f=flair_name%3A%22Extensions%22
StackOverflow: https://stackoverflow.com/questions/tagged/gnome-shell-extensions
Gio Source Code: https://gitlab.gnome.org/GNOME/glib/-/tree/main/gio
Gnome Shell imports.* Source Code: https://github.com/GNOME/gnome-shell/tree/main/js
Gnome Shell Source Code: https://github.com/GNOME/gnome-shell/tree/main/src