Set application display name and icon without an installed desktop file?

I did try using g_set_prgname() and g_set_application_name(), but they didn’t have any effect.

Let’s try simple example:

#!/usr/bin/gjs

imports.gi.versions.Gtk = "3.0";
const { GLib, Gio, Gtk } = imports.gi;

const application = new Gtk.Application({
    application_id: 'io.gitlab.simple.example',
    flags: Gio.ApplicationFlags.FLAGS_NONE
});

application.connect('activate', (app) => {
    let activeWindow = app.activeWindow;

    if (!activeWindow) {
        activeWindow = new Gtk.ApplicationWindow({
            application: app,
            title: "Test Window",
            defaultWidth: 600,
            defaultHeight: 400
        });
    }

    activeWindow.present();
});

GLib.set_prgname("abracadabra");

application.run(null);

Of course this doesn’t solve the problem anyway since prgname isn’t localised

That should be treated as an implementation detail, not an API. We don’t consider a .desktop file as optional, and we picked the WM_CLASS as fallback over “friendlier” options like the window title precisely to hint that the app is slightly broken.

There is no guarantee that we won’t change the fallback to “Unknown” or “Broken Shit” in the future.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.