From ab071e12aaf0c42b6e0921b94f96553c4a10bcbf Mon Sep 17 00:00:00 2001 From: bbedward Date: Mon, 5 Jan 2026 16:44:31 -0500 Subject: [PATCH] icons: fix transmission-gtk modded app ID again --- quickshell/Common/AppUsageHistoryData.qml | 93 ++++++++----------- quickshell/Common/Paths.qml | 9 +- quickshell/Modules/AppDrawer/AppLauncher.qml | 2 +- .../Modules/DankBar/Widgets/RunningApps.qml | 19 ++-- quickshell/Modules/Dock/DockAppButton.qml | 6 +- 5 files changed, 64 insertions(+), 65 deletions(-) diff --git a/quickshell/Common/AppUsageHistoryData.qml b/quickshell/Common/AppUsageHistoryData.qml index f92e7ce3..b608996a 100644 --- a/quickshell/Common/AppUsageHistoryData.qml +++ b/quickshell/Common/AppUsageHistoryData.qml @@ -7,120 +7,109 @@ import Quickshell import Quickshell.Io Singleton { - id: root - property var appUsageRanking: { - - } + property var appUsageRanking: {} Component.onCompleted: { - loadSettings() + loadSettings(); } function loadSettings() { - parseSettings(settingsFile.text()) + parseSettings(settingsFile.text()); } function parseSettings(content) { try { if (content && content.trim()) { - var settings = JSON.parse(content) - appUsageRanking = settings.appUsageRanking || {} + var settings = JSON.parse(content); + appUsageRanking = settings.appUsageRanking || {}; } - } catch (e) { - - } + } catch (e) {} } function saveSettings() { settingsFile.setText(JSON.stringify({ - "appUsageRanking": appUsageRanking - }, null, 2)) + "appUsageRanking": appUsageRanking + }, null, 2)); } function addAppUsage(app) { if (!app) - return - - var appId = app.id || (app.execString || app.exec || "") + return; + var appId = app.id || (app.execString || app.exec || ""); if (!appId) - return - - var currentRanking = Object.assign({}, appUsageRanking) + return; + var currentRanking = Object.assign({}, appUsageRanking); if (currentRanking[appId]) { - currentRanking[appId].usageCount = (currentRanking[appId].usageCount - || 1) + 1 - currentRanking[appId].lastUsed = Date.now() - currentRanking[appId].icon = app.icon || currentRanking[appId].icon - || "application-x-executable" - currentRanking[appId].name = app.name - || currentRanking[appId].name || "" + currentRanking[appId].usageCount = (currentRanking[appId].usageCount || 1) + 1; + currentRanking[appId].lastUsed = Date.now(); + currentRanking[appId].icon = app.icon ? String(app.icon) : (currentRanking[appId].icon || "application-x-executable"); + currentRanking[appId].name = app.name || currentRanking[appId].name || ""; } else { currentRanking[appId] = { "name": app.name || "", "exec": app.execString || app.exec || "", - "icon": app.icon || "application-x-executable", + "icon": app.icon ? String(app.icon) : "application-x-executable", "comment": app.comment || "", "usageCount": 1, "lastUsed": Date.now() - } + }; } - appUsageRanking = currentRanking - saveSettings() + appUsageRanking = currentRanking; + saveSettings(); } function getRankedApps() { - var apps = [] + var apps = []; for (var appId in appUsageRanking) { - var appData = appUsageRanking[appId] + var appData = appUsageRanking[appId]; apps.push({ - "id": appId, - "name": appData.name, - "exec": appData.exec, - "icon": appData.icon, - "comment": appData.comment, - "usageCount": appData.usageCount, - "lastUsed": appData.lastUsed - }) + "id": appId, + "name": appData.name, + "exec": appData.exec, + "icon": appData.icon, + "comment": appData.comment, + "usageCount": appData.usageCount, + "lastUsed": appData.lastUsed + }); } return apps.sort(function (a, b) { if (a.usageCount !== b.usageCount) - return b.usageCount - a.usageCount - return a.name.localeCompare(b.name) - }) + return b.usageCount - a.usageCount; + return a.name.localeCompare(b.name); + }); } function cleanupAppUsageRanking(availableAppIds) { - var currentRanking = Object.assign({}, appUsageRanking) - var hasChanges = false + var currentRanking = Object.assign({}, appUsageRanking); + var hasChanges = false; for (var appId in currentRanking) { if (availableAppIds.indexOf(appId) === -1) { - delete currentRanking[appId] - hasChanges = true + delete currentRanking[appId]; + hasChanges = true; } } if (hasChanges) { - appUsageRanking = currentRanking - saveSettings() + appUsageRanking = currentRanking; + saveSettings(); } } FileView { id: settingsFile - path: StandardPaths.writableLocation( - StandardPaths.GenericStateLocation) + "/DankMaterialShell/appusage.json" + path: StandardPaths.writableLocation(StandardPaths.GenericStateLocation) + "/DankMaterialShell/appusage.json" blockLoading: true blockWrites: true watchChanges: true onLoaded: { - parseSettings(settingsFile.text()) + parseSettings(settingsFile.text()); } onLoadFailed: error => {} } diff --git a/quickshell/Common/Paths.qml b/quickshell/Common/Paths.qml index 3c1e3a21..56dd58c2 100644 --- a/quickshell/Common/Paths.qml +++ b/quickshell/Common/Paths.qml @@ -52,8 +52,13 @@ Singleton { return "beeper"; if (appId === "home assistant desktop") return "homeassistant-desktop"; - if (appId.includes("com.transmissionbt.transmission")) - return "transmission"; + if (appId.includes("com.transmissionbt.transmission")) { + if (DesktopEntries.heuristicLookup("transmission-gtk")) + return "transmission-gtk"; + if (DesktopEntries.heuristicLookup("transmission")) + return "transmission"; + return "transmission-gtk"; + } return appId; } diff --git a/quickshell/Modules/AppDrawer/AppLauncher.qml b/quickshell/Modules/AppDrawer/AppLauncher.qml index fe2c8c09..f230b16b 100644 --- a/quickshell/Modules/AppDrawer/AppLauncher.qml +++ b/quickshell/Modules/AppDrawer/AppLauncher.qml @@ -186,7 +186,7 @@ Item { filteredModel.append({ "name": app.name || "", "exec": app.execString || app.exec || app.action || "", - "icon": app.icon !== undefined ? app.icon : (isPluginItem ? "" : "application-x-executable"), + "icon": app.icon !== undefined ? String(app.icon) : (isPluginItem ? "" : "application-x-executable"), "comment": app.comment || "", "categories": app.categories || [], "isPlugin": isPluginItem, diff --git a/quickshell/Modules/DankBar/Widgets/RunningApps.qml b/quickshell/Modules/DankBar/Widgets/RunningApps.qml index de8e0fb4..106717ff 100644 --- a/quickshell/Modules/DankBar/Widgets/RunningApps.qml +++ b/quickshell/Modules/DankBar/Widgets/RunningApps.qml @@ -327,7 +327,8 @@ Item { property int windowCount: isGrouped ? modelData.windows.length : 1 property string tooltipText: { root._desktopEntriesUpdateTrigger; - const desktopEntry = appId ? DesktopEntries.heuristicLookup(appId) : null; + const moddedId = Paths.moddedAppId(appId); + const desktopEntry = moddedId ? DesktopEntries.heuristicLookup(moddedId) : null; const appName = appId ? Paths.getAppName(appId, desktopEntry) : "Unknown"; if (isGrouped && windowCount > 1) { @@ -365,7 +366,8 @@ Item { root._desktopEntriesUpdateTrigger; if (!appId) return ""; - const desktopEntry = DesktopEntries.heuristicLookup(appId); + const moddedId = Paths.moddedAppId(appId); + const desktopEntry = DesktopEntries.heuristicLookup(moddedId); return Paths.getAppIcon(appId, desktopEntry); } smooth: true @@ -408,7 +410,8 @@ Item { if (!appId) return "?"; - const desktopEntry = DesktopEntries.heuristicLookup(appId); + const moddedId = Paths.moddedAppId(appId); + const desktopEntry = DesktopEntries.heuristicLookup(moddedId); const appName = Paths.getAppName(appId, desktopEntry); return appName.charAt(0).toUpperCase(); } @@ -436,7 +439,6 @@ Item { } } - // Window title text (only visible in expanded mode) StyledText { anchors.left: iconImg.right anchors.leftMargin: Theme.spacingXS @@ -576,7 +578,8 @@ Item { property int windowCount: isGrouped ? modelData.windows.length : 1 property string tooltipText: { root._desktopEntriesUpdateTrigger; - const desktopEntry = appId ? DesktopEntries.heuristicLookup(appId) : null; + const moddedId = Paths.moddedAppId(appId); + const desktopEntry = moddedId ? DesktopEntries.heuristicLookup(moddedId) : null; const appName = appId ? Paths.getAppName(appId, desktopEntry) : "Unknown"; if (isGrouped && windowCount > 1) { @@ -613,7 +616,8 @@ Item { root._desktopEntriesUpdateTrigger; if (!appId) return ""; - const desktopEntry = DesktopEntries.heuristicLookup(appId); + const moddedId = Paths.moddedAppId(appId); + const desktopEntry = DesktopEntries.heuristicLookup(moddedId); return Paths.getAppIcon(appId, desktopEntry); } smooth: true @@ -655,7 +659,8 @@ Item { if (!appId) return "?"; - const desktopEntry = DesktopEntries.heuristicLookup(appId); + const moddedId = Paths.moddedAppId(appId); + const desktopEntry = DesktopEntries.heuristicLookup(moddedId); const appName = Paths.getAppName(appId, desktopEntry); return appName.charAt(0).toUpperCase(); } diff --git a/quickshell/Modules/Dock/DockAppButton.qml b/quickshell/Modules/Dock/DockAppButton.qml index 70d7de78..07cff62b 100644 --- a/quickshell/Modules/Dock/DockAppButton.qml +++ b/quickshell/Modules/Dock/DockAppButton.qml @@ -225,7 +225,7 @@ Item { AppUsageHistoryData.addAppUsage({ "id": appData.appId, "name": pinnedEntry.name || appData.appId, - "icon": pinnedEntry.icon || "", + "icon": pinnedEntry.icon ? String(pinnedEntry.icon) : "", "exec": pinnedEntry.exec || "", "comment": pinnedEntry.comment || "" }); @@ -246,7 +246,7 @@ Item { AppUsageHistoryData.addAppUsage({ "id": appData.appId, "name": groupedEntry.name || appData.appId, - "icon": groupedEntry.icon || "", + "icon": groupedEntry.icon ? String(groupedEntry.icon) : "", "exec": groupedEntry.exec || "", "comment": groupedEntry.comment || "" }); @@ -316,7 +316,7 @@ Item { AppUsageHistoryData.addAppUsage({ "id": appData.appId, "name": desktopEntry.name || appData.appId, - "icon": desktopEntry.icon || "", + "icon": desktopEntry.icon ? String(desktopEntry.icon) : "", "exec": desktopEntry.exec || "", "comment": desktopEntry.comment || "" });