pragma Singleton import QtQuick import Quickshell import "AppMatching.js" as Matching Singleton { id: root readonly property var entries: DesktopEntries.applications.values readonly property var launchable: entries.filter(e => !e.noDisplay).slice().sort((a, b) => a.name.localeCompare(b.name)) property string error: "" function byId(id) { return entries.find(e => Matching.canonical(e.id) === Matching.canonical(id)) || null; } function icon(entry) { return entry && entry.icon ? Quickshell.iconPath(entry.icon, true) : ""; } function launch(entry, action) { if (!entry) { error = "This desktop entry is no longer installed."; return false; } if (entry.runInTerminal) { const terminal = ConfigService.data.dock.terminalCommand; if (!terminal.length) { error = "Set dock.terminalCommand to a terminal command argument array before launching terminal applications."; return false; } Quickshell.execDetached({ command: terminal.concat(action ? action.command : entry.command), workingDirectory: entry.workingDirectory }); } else if (action) action.execute(); else entry.execute(); error = ""; return true; } }