1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-30 17:42:06 -04:00

launcher: add indicators for flatpak/snap/appimage/nix

fixes #2251
This commit is contained in:
bbedward
2026-04-21 14:03:47 -04:00
parent 9139fd2fb1
commit cf382c0322
11 changed files with 560 additions and 1 deletions

View File

@@ -1442,7 +1442,8 @@ Item {
section: it.section || "",
isCore: it.isCore || false,
isBuiltInLauncher: it.isBuiltInLauncher || false,
pluginId: it.pluginId || ""
pluginId: it.pluginId || "",
source: it.source || ""
});
}
serializable.push({
@@ -1497,6 +1498,7 @@ Item {
isCore: it.isCore || false,
isBuiltInLauncher: it.isBuiltInLauncher || false,
pluginId: it.pluginId || "",
source: it.source || "",
data: {
id: it.id
},

View File

@@ -101,6 +101,39 @@ function detectIconType(iconName) {
return "material";
}
function classifyAppSource(app) {
if (!app)
return "";
var execRaw = app.execString || app.exec || "";
if (!execRaw && !app.id)
return "";
var exec = execRaw.toLowerCase();
var cmd0 = (app.command && app.command.length > 0) ? String(app.command[0]).toLowerCase() : "";
var id = (app.id || "").toLowerCase();
if (cmd0 === "flatpak" || exec.indexOf("flatpak run ") !== -1)
return "flatpak";
if (cmd0 === "snap"
|| exec.indexOf("bamf_desktop_file_hint=") !== -1
|| exec.indexOf("/snap/bin/") !== -1
|| exec.indexOf("/snap/core") !== -1
|| exec.indexOf("snap run ") === 0)
return "snap";
if (/\.appimage(\s|$|")/i.test(execRaw) || id.indexOf("appimagekit_") === 0)
return "appimage";
if (exec.indexOf("/nix/store/") !== -1
|| exec.indexOf("/run/current-system/sw/") !== -1
|| exec.indexOf("/etc/profiles/per-user/") !== -1)
return "nix";
return "system";
}
function sortPluginIdsByOrder(pluginIds, order) {
if (!order || order.length === 0)
return pluginIds;

View File

@@ -44,6 +44,15 @@ Rectangle {
cornerRadius: root.radius
}
SourceBadge {
anchors.top: parent.top
anchors.right: parent.right
anchors.margins: Theme.spacingXS
source: root.item?.type === "app" ? (root.item.source || "") : ""
glyphSize: 14
z: 1
}
Column {
anchors.centerIn: parent
anchors.margins: Theme.spacingS

View File

@@ -27,6 +27,7 @@ function transformApp(app, override, defaultActions, primaryActionLabel) {
data: app,
keywords: app.keywords || [],
actions: actions,
source: Utils.classifyAppSource(app),
primaryAction: {
name: primaryActionLabel,
icon: "open_in_new",

View File

@@ -191,6 +191,12 @@ Rectangle {
color: Theme.surfaceVariantText
}
}
SourceBadge {
anchors.verticalCenter: parent.verticalCenter
source: root.item?.type === "app" ? (root.item.source || "") : ""
glyphSize: 14
}
}
}
}

View File

@@ -0,0 +1,32 @@
import QtQuick
import Quickshell.Widgets
Item {
id: root
property string source: ""
property int glyphSize: 14
readonly property var sourceAsset: ({
"flatpak": "../../assets/package-sources/flatpak.svg",
"snap": "../../assets/package-sources/snap.svg",
"appimage": "../../assets/package-sources/appimage.svg",
"nix": "../../assets/package-sources/nix.svg"
})
readonly property string assetPath: sourceAsset[source] || ""
visible: assetPath.length > 0
implicitWidth: glyphSize
implicitHeight: glyphSize
IconImage {
anchors.fill: parent
source: root.assetPath ? Qt.resolvedUrl(root.assetPath) : ""
implicitSize: root.glyphSize * 2
backer.sourceSize: Qt.size(root.glyphSize * 2, root.glyphSize * 2)
smooth: true
mipmap: true
asynchronous: true
}
}

View File

@@ -168,6 +168,15 @@ Rectangle {
mipmap: true
}
}
SourceBadge {
anchors.top: parent.top
anchors.right: parent.right
anchors.margins: Theme.spacingXS
source: root.item?.type === "app" ? (root.item.source || "") : ""
glyphSize: 16
visible: !root.isSelected && !!source
}
}
}