Set desktop file StartupWMClass if renamed

tingping/wmclass
Patrick Griffis 2018-04-08 22:59:19 -04:00
parent cbca5b5dce
commit 47c68519e2
1 changed files with 15 additions and 1 deletions

View File

@ -2367,7 +2367,8 @@ builder_manifest_cleanup (BuilderManifest *self,
if (self->rename_icon ||
self->desktop_file_name_prefix ||
self->desktop_file_name_suffix)
self->desktop_file_name_suffix ||
self->rename_desktop_file)
{
g_autoptr(GFile) applications_dir = g_file_resolve_relative_path (app_root, "share/applications");
g_autofree char *desktop_basename = g_strdup_printf ("%s.desktop", self->id);
@ -2452,6 +2453,19 @@ builder_manifest_cleanup (BuilderManifest *self,
}
}
/* If the desktop file didn't set a custom wmclass it relied on the filename
matching the wmclass which is no longer true so lets manually set it back. */
if (self->rename_desktop_file
&& !g_strv_contains ((const char * const*)desktop_keys,
G_KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS))
{
g_autofree char *old_name = g_strndup (self->rename_desktop_file,
strlen (self->rename_desktop_file) - strlen (".desktop"));
g_key_file_set_string (keyfile, G_KEY_FILE_DESKTOP_GROUP,
G_KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS, old_name);
}
g_free (desktop_contents);
desktop_contents = g_key_file_to_data (keyfile, &desktop_size, error);
if (desktop_contents == NULL)