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,5 +1,6 @@
pragma ComponentBehavior: Bound pragma ComponentBehavior: Bound
import QtQuick
import Quickshell import Quickshell
import Quickshell.Hyprland import Quickshell.Hyprland
import Quickshell.Wayland import Quickshell.Wayland
@@ -147,6 +148,40 @@ Scope {
onPressed: shell.toggle() onPressed: shell.toggle()
} }
// SUPER — the launcher over an expanded rail, opened and closed as one.
GlobalShortcut {
name: "command"
description: "Open the launcher with the hyprchrome bar expanded"
onPressed: shell.toggleCommand()
}
// Whether the rail was expanded BY toggleCommand, so closing the launcher
// only collapses a rail it opened.
property bool commandExpanded: false
function toggleCommand() {
if (polkit.prompting || askpass.active)
return;
if (launcher.active) {
launcher.close();
return;
}
shell.commandExpanded = !shell.expanded;
shell.expanded = true;
launcher.active = true;
}
// The launcher closes itself (ESC, launch, click-off), so collapse follows it.
Connections {
target: launcher
function onActiveChanged() {
if (!launcher.active && shell.commandExpanded) {
shell.commandExpanded = false;
shell.expanded = false;
}
}
}
// Backdrop first: it is a layer below the bar, so stacking does not depend // Backdrop first: it is a layer below the bar, so stacking does not depend
// on creation order, but keeping the declaration order the same as the // on creation order, but keeping the declaration order the same as the
// visual order costs nothing. // visual order costs nothing.
@@ -236,7 +271,7 @@ Scope {
screen: shell.focusedScreen screen: shell.focusedScreen
} }
// Primary application launcher — SUPER_L. Migrated out of // Primary application launcher — SUPER_L (via `command` above). Migrated out of
// widgets/launcher/; the ten remaining variants are still evaluation copies // widgets/launcher/; the ten remaining variants are still evaluation copies
// and stay in shell.qml. Declared after the bar for the same reason the // and stay in shell.qml. Declared after the bar for the same reason the
// prompt is: while it is open the bar is on Overlay too, and there is no // prompt is: while it is open the bar is on Overlay too, and there is no
@@ -6,7 +6,7 @@ import Quickshell.Wayland
import QtQuick import QtQuick
import qs.HyprChrome.Theme import qs.HyprChrome.Theme
// Primary application launcher — the one on SUPER_L. // Primary application launcher — the one on SUPER_L (via HyprChromeShell).
// //
// Migrated from widgets/launcher/ApplicationLauncher.qml. Two things changed in // Migrated from widgets/launcher/ApplicationLauncher.qml. Two things changed in
// the move, both because HyprChromeShell now owns the state its surfaces share: // the move, both because HyprChromeShell now owns the state its surfaces share:
@@ -34,11 +34,8 @@ Scope {
function toggle() { root.active = !root.active; } function toggle() { root.active = !root.active; }
function close() { root.active = false; } function close() { root.active = false; }
// The name is legacy: this was "variant 8" of eleven, and both SUPER_L (via // Launcher alone, on SUPER CTRL 8. SUPER_L goes through the shell's
// open_launcher.sh) and SUPER CTRL 8 still dispatch quickshell:launcher8. // `command` shortcut instead, which also expands the rail.
// Renaming it means editing hosts/terra/home/hyprland.nix AND the script
// together, and neither takes effect until a deploy — so the shortcut would
// be dead in the running session in between. Kept as-is deliberately.
GlobalShortcut { GlobalShortcut {
name: "launcher8" name: "launcher8"
description: "Toggle dense application command index" description: "Toggle dense application command index"
@@ -83,9 +80,22 @@ Scope {
root.active = false; root.active = false;
} }
// Hyprland runs a Lua config, which rejects a bare `dispatch exit`.
readonly property var powerCommands: ({
logout: ["hyprctl", "dispatch", "hl.dsp.exit()"],
reboot: ["systemctl", "reboot"],
shutdown: ["systemctl", "poweroff"]
})
function power(action) {
root.active = false;
Quickshell.execDetached(win.powerCommands[action]);
}
onVisibleChanged: { onVisibleChanged: {
if (visible) { if (visible) {
content.clearSearch(); content.clearSearch();
content.disarmPower();
selectedIndex = 0; selectedIndex = 0;
content.focusSearch(); content.focusSearch();
} }
@@ -115,11 +125,17 @@ Scope {
transformOrigin: Item.Center transformOrigin: Item.Center
apps: model.apps apps: model.apps
selectedIndex: win.selectedIndex selectedIndex: win.selectedIndex
sortMode: model.sortMode
onSelectionRequested: index => win.selectedIndex = win.clampSelection(index) onSelectionRequested: index => win.selectedIndex = win.clampSelection(index)
onMoveRequested: delta => win.move(delta) onMoveRequested: delta => win.move(delta)
onLaunchRequested: index => win.launch(index) onLaunchRequested: index => win.launch(index)
onDismissRequested: root.close() onDismissRequested: root.close()
onSortToggleRequested: {
model.toggleSort();
win.selectedIndex = 0;
}
onPowerRequested: action => win.power(action)
} }
} }
} }
@@ -17,6 +17,10 @@ Item {
property int selectedIndex: 0 property int selectedIndex: 0
property bool showIcons: true property bool showIcons: true
property alias query: searchInput.text property alias query: searchInput.text
property string sortMode: "usage"
// Power action awaiting its confirming second click; "" when none.
property string armedPower: ""
readonly property var selectedApp: apps.length > 0 && selectedIndex >= 0 && selectedIndex < apps.length readonly property var selectedApp: apps.length > 0 && selectedIndex >= 0 && selectedIndex < apps.length
? apps[selectedIndex] : null ? apps[selectedIndex] : null
@@ -25,9 +29,29 @@ Item {
signal moveRequested(int delta) signal moveRequested(int delta)
signal launchRequested(int index) signal launchRequested(int index)
signal dismissRequested signal dismissRequested
signal sortToggleRequested
signal powerRequested(string action)
function focusSearch() { searchInput.forceActiveFocus(); } function focusSearch() { searchInput.forceActiveFocus(); }
function clearSearch() { searchInput.text = ""; } function clearSearch() { searchInput.text = ""; }
function disarmPower() { root.armedPower = ""; }
// First click arms, second (within the timeout) fires: a stray click must
// not end the session.
function pressPower(action) {
if (root.armedPower === action) {
root.armedPower = "";
root.powerRequested(action);
} else {
root.armedPower = action;
}
}
Timer {
running: root.armedPower !== ""
interval: 3000
onTriggered: root.disarmPower()
}
implicitWidth: 1080 implicitWidth: 1080
implicitHeight: 620 implicitHeight: 620
@@ -121,6 +145,11 @@ Item {
onTextChanged: root.selectionRequested(0) onTextChanged: root.selectionRequested(0)
Keys.onPressed: event => { Keys.onPressed: event => {
if (event.key === Qt.Key_S && (event.modifiers & Qt.ControlModifier)) {
root.sortToggleRequested();
event.accepted = true;
return;
}
switch (event.key) { switch (event.key) {
case Qt.Key_Down: case Qt.Key_Down:
case Qt.Key_Tab: case Qt.Key_Tab:
@@ -162,16 +191,24 @@ Item {
} }
} }
Rectangle { MouseArea {
id: sortChip
Layout.preferredWidth: 84 Layout.preferredWidth: 84
Layout.preferredHeight: 22 Layout.preferredHeight: 22
color: Theme.accentAlpha(0.12) hoverEnabled: true
border.width: 1 cursorShape: Qt.PointingHandCursor
border.color: Theme.hair onClicked: root.sortToggleRequested()
Rectangle {
anchors.fill: parent
color: sortChip.containsMouse ? Theme.accentAlpha(0.28) : Theme.accentAlpha(0.12)
border.width: 1
border.color: sortChip.containsMouse ? Theme.accent : Theme.hair
}
Text { Text {
anchors.centerIn: parent anchors.centerIn: parent
text: "LIVE INDEX" text: root.sortMode === "usage" ? "SORT: USED" : "SORT: A–Z"
color: Theme.accent color: Theme.accent
font.family: Theme.microFont font.family: Theme.microFont
font.pixelSize: 7 font.pixelSize: 7
@@ -191,7 +228,7 @@ Item {
height: 424 height: 424
panelId: "IDX" panelId: "IDX"
title: "APPLICATION TABLE" title: "APPLICATION TABLE"
meta: root.query.length > 0 ? "FILTER ACTIVE" : "A–Z / LOCAL" meta: (root.query.length > 0 ? "FILTER ACTIVE" : "LOCAL") + (root.sortMode === "usage" ? " / MOST USED" : " / A–Z")
ListView { ListView {
id: appList id: appList
@@ -587,13 +624,46 @@ Item {
KeyHint { keyText: "↑ ↓"; actionText: "SELECT" } KeyHint { keyText: "↑ ↓"; actionText: "SELECT" }
KeyHint { keyText: "ENTER"; actionText: "EXECUTE" } KeyHint { keyText: "ENTER"; actionText: "EXECUTE" }
KeyHint { keyText: "ESC"; actionText: "ABORT" } KeyHint { keyText: "ESC"; actionText: "ABORT" }
KeyHint { keyText: "CTRL+S"; actionText: "SORT" }
Item { Layout.fillWidth: true } Item { Layout.fillWidth: true }
MicroText { text: "QRY:" + (root.query.length > 0 ? "ACTIVE" : "IDLE") } MicroText { text: "QRY:" + (root.query.length > 0 ? "ACTIVE" : "IDLE") }
MicroText { text: "CRC // A7F2" } Rectangle { Layout.preferredWidth: 1; Layout.preferredHeight: 22; color: Theme.hair }
Rectangle {
Layout.preferredWidth: 76 Repeater {
Layout.preferredHeight: 4 model: [
color: Theme.accent { action: "logout", label: "LOGOUT" },
{ action: "reboot", label: "REBOOT" },
{ action: "shutdown", label: "SHUTDOWN" }
]
MouseArea {
id: powerButton
required property var modelData
readonly property bool armed: root.armedPower === modelData.action
Layout.preferredWidth: 96
Layout.preferredHeight: 26
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: root.pressPower(modelData.action)
Rectangle {
anchors.fill: parent
color: powerButton.armed ? Theme.hot : powerButton.containsMouse ? Theme.accentAlpha(0.28) : Theme.accentAlpha(0.10)
border.width: 1
border.color: powerButton.armed ? Theme.hot : powerButton.containsMouse ? Theme.accent : Theme.hair
}
Text {
anchors.centerIn: parent
text: powerButton.armed ? "CONFIRM" : powerButton.modelData.label
color: powerButton.armed ? Theme.surface : Theme.accent
font.family: Theme.microFont
font.pixelSize: 8
font.bold: true
font.letterSpacing: 1
}
}
} }
} }
} }
@@ -1,44 +1,85 @@
import Quickshell import Quickshell
import Quickshell.Io
import QtQuick 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). // Set `search`; read `apps` (a ranked, filtered list of DesktopEntry).
QtObject { QtObject {
id: root id: root
property string search: "" 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 // `keywords`/`categories` come through as string lists, so coerce every
// field to a string before matching (String([]) joins with commas). // field to a string before matching (String([]) joins with commas).
function haystack(a) { function haystack(a) {
return (String(a.name || "") + " " + String(a.genericName || "") + " " + String(a.comment || "") + " " + String(a.keywords || "")).toLowerCase(); 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: { readonly property var apps: {
const all = DesktopEntries.applications.values.filter(a => !a.noDisplay); const all = DesktopEntries.applications.values.filter(a => !a.noDisplay);
const q = root.search.trim().toLowerCase(); const q = root.search.trim().toLowerCase();
if (q.length === 0) 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)); 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) => { return matches.slice().sort((x, y) => {
const xs = String(x.name).toLowerCase().startsWith(q) ? 0 : 1; const xs = String(x.name).toLowerCase().startsWith(q) ? 0 : 1;
const ys = String(y.name).toLowerCase().startsWith(q) ? 0 : 1; const ys = String(y.name).toLowerCase().startsWith(q) ? 0 : 1;
if (xs !== ys) if (xs !== ys)
return xs - ys; return xs - ys;
return String(x.name).localeCompare(String(y.name)); return root.byOrder(x, y);
}); });
} }
function launch(index) { function launch(index) {
const list = root.apps; const list = root.apps;
if (index >= 0 && index < list.length) { 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 true;
} }
return false; 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: ({})
}
}
} }
+1 -1
View File
@@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
hyprctl dispatch 'hl.dsp.global ("quickshell:launcher8")' hyprctl dispatch 'hl.dsp.global ("quickshell:command")'