feat(terra): launcher most-used sort, power buttons, SUPER opens rail

- Launcher sorts by launch count by default (persisted in quickshell's
  state dir); Ctrl+S or the sort chip toggles A–Z.
- Logout/Reboot/Shutdown in the footer, each needing a confirming click.
- SUPER now opens the launcher with the rail expanded; closing the
  launcher collapses the rail again unless it was already open.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-25 01:26:44 +02:00
co-authored by Claude Opus 5.5
parent f84611bc6e
commit 896368ef56
5 changed files with 186 additions and 24 deletions
@@ -1,44 +1,85 @@
import Quickshell
import Quickshell.Io
import QtQuick
// Non-visual, reusable app-search model shared by every launcher variant.
// Non-visual app-search model for the launcher.
// Set `search`; read `apps` (a ranked, filtered list of DesktopEntry).
QtObject {
id: root
property string search: ""
// "usage" (most launched first) | "name". Persisted with the counts.
readonly property string sortMode: store.sortMode
function toggleSort() {
store.sortMode = store.sortMode === "usage" ? "name" : "usage";
}
function uses(a) {
return store.counts[a.id] ?? 0;
}
// `keywords`/`categories` come through as string lists, so coerce every
// field to a string before matching (String([]) joins with commas).
function haystack(a) {
return (String(a.name || "") + " " + String(a.genericName || "") + " " + String(a.comment || "") + " " + String(a.keywords || "")).toLowerCase();
}
function byOrder(x, y) {
if (root.sortMode === "usage") {
const d = root.uses(y) - root.uses(x);
if (d !== 0)
return d;
}
return String(x.name).localeCompare(String(y.name));
}
readonly property var apps: {
const all = DesktopEntries.applications.values.filter(a => !a.noDisplay);
const q = root.search.trim().toLowerCase();
if (q.length === 0)
return all.slice().sort((x, y) => String(x.name).localeCompare(String(y.name)));
return all.slice().sort(root.byOrder);
const matches = all.filter(a => root.haystack(a).includes(q));
// Prefix matches on the visible name rank first, then alphabetical.
// Prefix matches on the visible name rank first, then the sort mode.
return matches.slice().sort((x, y) => {
const xs = String(x.name).toLowerCase().startsWith(q) ? 0 : 1;
const ys = String(y.name).toLowerCase().startsWith(q) ? 0 : 1;
if (xs !== ys)
return xs - ys;
return String(x.name).localeCompare(String(y.name));
return root.byOrder(x, y);
});
}
function launch(index) {
const list = root.apps;
if (index >= 0 && index < list.length) {
list[index].execute();
const app = list[index];
app.execute();
// Reassigned, not mutated: an in-place write notifies nothing.
const counts = Object.assign({}, store.counts);
counts[app.id] = (counts[app.id] ?? 0) + 1;
store.counts = counts;
return true;
}
return false;
}
readonly property var file: FileView {
path: Quickshell.statePath("launcher.json")
onAdapterUpdated: writeAdapter()
onLoadFailed: error => {
if (error === FileViewError.FileNotFound)
writeAdapter();
}
JsonAdapter {
id: store
property string sortMode: "usage"
property var counts: ({})
}
}
}