From f65b9f2df5bf913f8c152ea770795d2cdcb14c6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Tue, 7 Jan 2025 19:09:01 +0100 Subject: [PATCH] desktop-icons: Fix '%k' in .desktop files In order to support Link-type .desktop files, we load the file ourselves, and then create the AppInfo from the loaded keyfile to avoid reading the file twice. Unfortunately that means that the AppInfo loses the filename information, which is necessary to substitute the '%k' macro. In order to support both the macro and Link-type .desktop files, we have to take the hit and let GIO read the file again. --- extensions/desktop-icons/fileItem.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/extensions/desktop-icons/fileItem.js b/extensions/desktop-icons/fileItem.js index 1c9a1e55..c765967b 100644 --- a/extensions/desktop-icons/fileItem.js +++ b/extensions/desktop-icons/fileItem.js @@ -241,13 +241,14 @@ var FileItem = class { if (this._isDesktopFile) { try { const keyFile = new GLib.KeyFile(); - keyFile.load_from_file(this._file.get_path(), GLib.KeyFileFlags.NONE); + const path = this._file.get_path(); + keyFile.load_from_file(path, GLib.KeyFileFlags.NONE); const type = keyFile.get_string( GLib.KEY_FILE_DESKTOP_GROUP, GLib.KEY_FILE_DESKTOP_KEY_TYPE); switch (type) { case GLib.KEY_FILE_DESKTOP_TYPE_APPLICATION: - this._desktopFile = Gio.DesktopAppInfo.new_from_keyfile(keyFile); + this._desktopFile = Gio.DesktopAppInfo.new_from_filename(path); if (!this._desktopFile) { log(`Couldn’t parse ${this._displayName} as a desktop file, will treat it as a regular file.`); this._isValidDesktopFile = false; -- 2.47.1