mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-30 08:22:51 -05:00
icons: fix transmission-gtk modded app ID again
This commit is contained in:
@@ -7,75 +7,65 @@ import Quickshell
|
|||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
|
|
||||||
Singleton {
|
Singleton {
|
||||||
|
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property var appUsageRanking: {
|
property var appUsageRanking: {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
loadSettings()
|
loadSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadSettings() {
|
function loadSettings() {
|
||||||
parseSettings(settingsFile.text())
|
parseSettings(settingsFile.text());
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseSettings(content) {
|
function parseSettings(content) {
|
||||||
try {
|
try {
|
||||||
if (content && content.trim()) {
|
if (content && content.trim()) {
|
||||||
var settings = JSON.parse(content)
|
var settings = JSON.parse(content);
|
||||||
appUsageRanking = settings.appUsageRanking || {}
|
appUsageRanking = settings.appUsageRanking || {};
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveSettings() {
|
function saveSettings() {
|
||||||
settingsFile.setText(JSON.stringify({
|
settingsFile.setText(JSON.stringify({
|
||||||
"appUsageRanking": appUsageRanking
|
"appUsageRanking": appUsageRanking
|
||||||
}, null, 2))
|
}, null, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
function addAppUsage(app) {
|
function addAppUsage(app) {
|
||||||
if (!app)
|
if (!app)
|
||||||
return
|
return;
|
||||||
|
var appId = app.id || (app.execString || app.exec || "");
|
||||||
var appId = app.id || (app.execString || app.exec || "")
|
|
||||||
if (!appId)
|
if (!appId)
|
||||||
return
|
return;
|
||||||
|
var currentRanking = Object.assign({}, appUsageRanking);
|
||||||
var currentRanking = Object.assign({}, appUsageRanking)
|
|
||||||
|
|
||||||
if (currentRanking[appId]) {
|
if (currentRanking[appId]) {
|
||||||
currentRanking[appId].usageCount = (currentRanking[appId].usageCount
|
currentRanking[appId].usageCount = (currentRanking[appId].usageCount || 1) + 1;
|
||||||
|| 1) + 1
|
currentRanking[appId].lastUsed = Date.now();
|
||||||
currentRanking[appId].lastUsed = Date.now()
|
currentRanking[appId].icon = app.icon ? String(app.icon) : (currentRanking[appId].icon || "application-x-executable");
|
||||||
currentRanking[appId].icon = app.icon || currentRanking[appId].icon
|
currentRanking[appId].name = app.name || currentRanking[appId].name || "";
|
||||||
|| "application-x-executable"
|
|
||||||
currentRanking[appId].name = app.name
|
|
||||||
|| currentRanking[appId].name || ""
|
|
||||||
} else {
|
} else {
|
||||||
currentRanking[appId] = {
|
currentRanking[appId] = {
|
||||||
"name": app.name || "",
|
"name": app.name || "",
|
||||||
"exec": app.execString || app.exec || "",
|
"exec": app.execString || app.exec || "",
|
||||||
"icon": app.icon || "application-x-executable",
|
"icon": app.icon ? String(app.icon) : "application-x-executable",
|
||||||
"comment": app.comment || "",
|
"comment": app.comment || "",
|
||||||
"usageCount": 1,
|
"usageCount": 1,
|
||||||
"lastUsed": Date.now()
|
"lastUsed": Date.now()
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
appUsageRanking = currentRanking
|
appUsageRanking = currentRanking;
|
||||||
saveSettings()
|
saveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRankedApps() {
|
function getRankedApps() {
|
||||||
var apps = []
|
var apps = [];
|
||||||
for (var appId in appUsageRanking) {
|
for (var appId in appUsageRanking) {
|
||||||
var appData = appUsageRanking[appId]
|
var appData = appUsageRanking[appId];
|
||||||
apps.push({
|
apps.push({
|
||||||
"id": appId,
|
"id": appId,
|
||||||
"name": appData.name,
|
"name": appData.name,
|
||||||
@@ -84,43 +74,42 @@ Singleton {
|
|||||||
"comment": appData.comment,
|
"comment": appData.comment,
|
||||||
"usageCount": appData.usageCount,
|
"usageCount": appData.usageCount,
|
||||||
"lastUsed": appData.lastUsed
|
"lastUsed": appData.lastUsed
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return apps.sort(function (a, b) {
|
return apps.sort(function (a, b) {
|
||||||
if (a.usageCount !== b.usageCount)
|
if (a.usageCount !== b.usageCount)
|
||||||
return b.usageCount - a.usageCount
|
return b.usageCount - a.usageCount;
|
||||||
return a.name.localeCompare(b.name)
|
return a.name.localeCompare(b.name);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanupAppUsageRanking(availableAppIds) {
|
function cleanupAppUsageRanking(availableAppIds) {
|
||||||
var currentRanking = Object.assign({}, appUsageRanking)
|
var currentRanking = Object.assign({}, appUsageRanking);
|
||||||
var hasChanges = false
|
var hasChanges = false;
|
||||||
|
|
||||||
for (var appId in currentRanking) {
|
for (var appId in currentRanking) {
|
||||||
if (availableAppIds.indexOf(appId) === -1) {
|
if (availableAppIds.indexOf(appId) === -1) {
|
||||||
delete currentRanking[appId]
|
delete currentRanking[appId];
|
||||||
hasChanges = true
|
hasChanges = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasChanges) {
|
if (hasChanges) {
|
||||||
appUsageRanking = currentRanking
|
appUsageRanking = currentRanking;
|
||||||
saveSettings()
|
saveSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FileView {
|
FileView {
|
||||||
id: settingsFile
|
id: settingsFile
|
||||||
|
|
||||||
path: StandardPaths.writableLocation(
|
path: StandardPaths.writableLocation(StandardPaths.GenericStateLocation) + "/DankMaterialShell/appusage.json"
|
||||||
StandardPaths.GenericStateLocation) + "/DankMaterialShell/appusage.json"
|
|
||||||
blockLoading: true
|
blockLoading: true
|
||||||
blockWrites: true
|
blockWrites: true
|
||||||
watchChanges: true
|
watchChanges: true
|
||||||
onLoaded: {
|
onLoaded: {
|
||||||
parseSettings(settingsFile.text())
|
parseSettings(settingsFile.text());
|
||||||
}
|
}
|
||||||
onLoadFailed: error => {}
|
onLoadFailed: error => {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,8 +52,13 @@ Singleton {
|
|||||||
return "beeper";
|
return "beeper";
|
||||||
if (appId === "home assistant desktop")
|
if (appId === "home assistant desktop")
|
||||||
return "homeassistant-desktop";
|
return "homeassistant-desktop";
|
||||||
if (appId.includes("com.transmissionbt.transmission"))
|
if (appId.includes("com.transmissionbt.transmission")) {
|
||||||
|
if (DesktopEntries.heuristicLookup("transmission-gtk"))
|
||||||
|
return "transmission-gtk";
|
||||||
|
if (DesktopEntries.heuristicLookup("transmission"))
|
||||||
return "transmission";
|
return "transmission";
|
||||||
|
return "transmission-gtk";
|
||||||
|
}
|
||||||
return appId;
|
return appId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ Item {
|
|||||||
filteredModel.append({
|
filteredModel.append({
|
||||||
"name": app.name || "",
|
"name": app.name || "",
|
||||||
"exec": app.execString || app.exec || app.action || "",
|
"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 || "",
|
"comment": app.comment || "",
|
||||||
"categories": app.categories || [],
|
"categories": app.categories || [],
|
||||||
"isPlugin": isPluginItem,
|
"isPlugin": isPluginItem,
|
||||||
|
|||||||
@@ -327,7 +327,8 @@ Item {
|
|||||||
property int windowCount: isGrouped ? modelData.windows.length : 1
|
property int windowCount: isGrouped ? modelData.windows.length : 1
|
||||||
property string tooltipText: {
|
property string tooltipText: {
|
||||||
root._desktopEntriesUpdateTrigger;
|
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";
|
const appName = appId ? Paths.getAppName(appId, desktopEntry) : "Unknown";
|
||||||
|
|
||||||
if (isGrouped && windowCount > 1) {
|
if (isGrouped && windowCount > 1) {
|
||||||
@@ -365,7 +366,8 @@ Item {
|
|||||||
root._desktopEntriesUpdateTrigger;
|
root._desktopEntriesUpdateTrigger;
|
||||||
if (!appId)
|
if (!appId)
|
||||||
return "";
|
return "";
|
||||||
const desktopEntry = DesktopEntries.heuristicLookup(appId);
|
const moddedId = Paths.moddedAppId(appId);
|
||||||
|
const desktopEntry = DesktopEntries.heuristicLookup(moddedId);
|
||||||
return Paths.getAppIcon(appId, desktopEntry);
|
return Paths.getAppIcon(appId, desktopEntry);
|
||||||
}
|
}
|
||||||
smooth: true
|
smooth: true
|
||||||
@@ -408,7 +410,8 @@ Item {
|
|||||||
if (!appId)
|
if (!appId)
|
||||||
return "?";
|
return "?";
|
||||||
|
|
||||||
const desktopEntry = DesktopEntries.heuristicLookup(appId);
|
const moddedId = Paths.moddedAppId(appId);
|
||||||
|
const desktopEntry = DesktopEntries.heuristicLookup(moddedId);
|
||||||
const appName = Paths.getAppName(appId, desktopEntry);
|
const appName = Paths.getAppName(appId, desktopEntry);
|
||||||
return appName.charAt(0).toUpperCase();
|
return appName.charAt(0).toUpperCase();
|
||||||
}
|
}
|
||||||
@@ -436,7 +439,6 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Window title text (only visible in expanded mode)
|
|
||||||
StyledText {
|
StyledText {
|
||||||
anchors.left: iconImg.right
|
anchors.left: iconImg.right
|
||||||
anchors.leftMargin: Theme.spacingXS
|
anchors.leftMargin: Theme.spacingXS
|
||||||
@@ -576,7 +578,8 @@ Item {
|
|||||||
property int windowCount: isGrouped ? modelData.windows.length : 1
|
property int windowCount: isGrouped ? modelData.windows.length : 1
|
||||||
property string tooltipText: {
|
property string tooltipText: {
|
||||||
root._desktopEntriesUpdateTrigger;
|
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";
|
const appName = appId ? Paths.getAppName(appId, desktopEntry) : "Unknown";
|
||||||
|
|
||||||
if (isGrouped && windowCount > 1) {
|
if (isGrouped && windowCount > 1) {
|
||||||
@@ -613,7 +616,8 @@ Item {
|
|||||||
root._desktopEntriesUpdateTrigger;
|
root._desktopEntriesUpdateTrigger;
|
||||||
if (!appId)
|
if (!appId)
|
||||||
return "";
|
return "";
|
||||||
const desktopEntry = DesktopEntries.heuristicLookup(appId);
|
const moddedId = Paths.moddedAppId(appId);
|
||||||
|
const desktopEntry = DesktopEntries.heuristicLookup(moddedId);
|
||||||
return Paths.getAppIcon(appId, desktopEntry);
|
return Paths.getAppIcon(appId, desktopEntry);
|
||||||
}
|
}
|
||||||
smooth: true
|
smooth: true
|
||||||
@@ -655,7 +659,8 @@ Item {
|
|||||||
if (!appId)
|
if (!appId)
|
||||||
return "?";
|
return "?";
|
||||||
|
|
||||||
const desktopEntry = DesktopEntries.heuristicLookup(appId);
|
const moddedId = Paths.moddedAppId(appId);
|
||||||
|
const desktopEntry = DesktopEntries.heuristicLookup(moddedId);
|
||||||
const appName = Paths.getAppName(appId, desktopEntry);
|
const appName = Paths.getAppName(appId, desktopEntry);
|
||||||
return appName.charAt(0).toUpperCase();
|
return appName.charAt(0).toUpperCase();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ Item {
|
|||||||
AppUsageHistoryData.addAppUsage({
|
AppUsageHistoryData.addAppUsage({
|
||||||
"id": appData.appId,
|
"id": appData.appId,
|
||||||
"name": pinnedEntry.name || appData.appId,
|
"name": pinnedEntry.name || appData.appId,
|
||||||
"icon": pinnedEntry.icon || "",
|
"icon": pinnedEntry.icon ? String(pinnedEntry.icon) : "",
|
||||||
"exec": pinnedEntry.exec || "",
|
"exec": pinnedEntry.exec || "",
|
||||||
"comment": pinnedEntry.comment || ""
|
"comment": pinnedEntry.comment || ""
|
||||||
});
|
});
|
||||||
@@ -246,7 +246,7 @@ Item {
|
|||||||
AppUsageHistoryData.addAppUsage({
|
AppUsageHistoryData.addAppUsage({
|
||||||
"id": appData.appId,
|
"id": appData.appId,
|
||||||
"name": groupedEntry.name || appData.appId,
|
"name": groupedEntry.name || appData.appId,
|
||||||
"icon": groupedEntry.icon || "",
|
"icon": groupedEntry.icon ? String(groupedEntry.icon) : "",
|
||||||
"exec": groupedEntry.exec || "",
|
"exec": groupedEntry.exec || "",
|
||||||
"comment": groupedEntry.comment || ""
|
"comment": groupedEntry.comment || ""
|
||||||
});
|
});
|
||||||
@@ -316,7 +316,7 @@ Item {
|
|||||||
AppUsageHistoryData.addAppUsage({
|
AppUsageHistoryData.addAppUsage({
|
||||||
"id": appData.appId,
|
"id": appData.appId,
|
||||||
"name": desktopEntry.name || appData.appId,
|
"name": desktopEntry.name || appData.appId,
|
||||||
"icon": desktopEntry.icon || "",
|
"icon": desktopEntry.icon ? String(desktopEntry.icon) : "",
|
||||||
"exec": desktopEntry.exec || "",
|
"exec": desktopEntry.exec || "",
|
||||||
"comment": desktopEntry.comment || ""
|
"comment": desktopEntry.comment || ""
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user