mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
icons: fix transmission-gtk modded app ID again
This commit is contained in:
@@ -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 => {}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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 || ""
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user