fixed launcher nav + headroom completion

This commit is contained in:
nvrl committed 2026-09-17 12:21:09 +02:00
1 parent 51dc5e80c4
commit 5f3a44f82d
6 files changed
+87 -160

No files matched your search

+1 -46
View File
@@ -1,46 +1 @@
# Print an optspec for argparse to handle cmd's options that are independent of any subcommand.
function __fish_enqs_guard_global_optspecs
string join \n h/help V/version
end
function __fish_enqs_guard_needs_command
# Figure out if the current invocation already has a command.
set -l cmd (commandline -opc)
set -e cmd[1]
argparse -s (__fish_enqs_guard_global_optspecs) -- $cmd 2>/dev/null
or return
if set -q argv[1]
# Also print the command, so this can be used to figure out what it is.
echo $argv[1]
return 1
end
return 0
end
function __fish_enqs_guard_using_subcommand
set -l cmd (__fish_enqs_guard_needs_command)
test -z "$cmd"
and return 1
contains -- $cmd[1] $argv
end
complete -c enqs-guard -n "__fish_enqs_guard_needs_command" -s h -l help -d 'Print help (see more with \'--help\')'
complete -c enqs-guard -n "__fish_enqs_guard_needs_command" -s V -l version -d 'Print version'
complete -c enqs-guard -n "__fish_enqs_guard_needs_command" -f -a "hook" -d 'Answer as a PreToolUse hook; reads the event from stdin (Claude Code)'
complete -c enqs-guard -n "__fish_enqs_guard_needs_command" -f -a "session-start" -d 'Answer as a SessionStart hook (Claude Code)'
complete -c enqs-guard -n "__fish_enqs_guard_needs_command" -f -a "status" -d 'Show the current guard state'
complete -c enqs-guard -n "__fish_enqs_guard_needs_command" -f -a "init" -d 'Create a configuration template'
complete -c enqs-guard -n "__fish_enqs_guard_needs_command" -f -a "mode" -d 'Set what the guard does'
complete -c enqs-guard -n "__fish_enqs_guard_needs_command" -f -a "add" -d 'Put a project on one of the lists'
complete -c enqs-guard -n "__fish_enqs_guard_needs_command" -f -a "remove" -d 'Take a project off one of the lists'
complete -c enqs-guard -n "__fish_enqs_guard_needs_command" -f -a "check" -d 'Check whether a path is blocked'
complete -c enqs-guard -n "__fish_enqs_guard_needs_command" -f -a "completions" -d 'Print a tab completion script for a shell'
complete -c enqs-guard -n "__fish_enqs_guard_using_subcommand hook" -s h -l help -d 'Print help'
complete -c enqs-guard -n "__fish_enqs_guard_using_subcommand session-start" -s h -l help -d 'Print help'
complete -c enqs-guard -n "__fish_enqs_guard_using_subcommand status" -s h -l help -d 'Print help'
complete -c enqs-guard -n "__fish_enqs_guard_using_subcommand init" -s h -l help -d 'Print help'
complete -c enqs-guard -n "__fish_enqs_guard_using_subcommand mode" -s h -l help -d 'Print help (see more with \'--help\')'
complete -c enqs-guard -n "__fish_enqs_guard_using_subcommand add" -s h -l help -d 'Print help'
complete -c enqs-guard -n "__fish_enqs_guard_using_subcommand remove" -s h -l help -d 'Print help'
complete -c enqs-guard -n "__fish_enqs_guard_using_subcommand check" -s h -l help -d 'Print help'
complete -c enqs-guard -n "__fish_enqs_guard_using_subcommand completions" -s h -l help -d 'Print help'
complete --keep-order --exclusive --command enqs-guard --arguments "(COMPLETE=fish enqs-guard -- (commandline --current-process --tokenize --cut-at-cursor) (commandline --current-token))"
+1
View File
@@ -0,0 +1 @@
complete --keep-order --exclusive --command enqs-headroom --arguments "(COMPLETE=fish enqs-headroom -- (commandline --current-process --tokenize --cut-at-cursor) (commandline --current-token))"
+1 -70
View File
@@ -1,70 +1 @@
# Print an optspec for argparse to handle cmd's options that are independent of any subcommand.
function __fish_enqs_jail_global_optspecs
string join \n h/help V/version
end
function __fish_enqs_jail_needs_command
# Figure out if the current invocation already has a command.
set -l cmd (commandline -opc)
set -e cmd[1]
argparse -s (__fish_enqs_jail_global_optspecs) -- $cmd 2>/dev/null
or return
if set -q argv[1]
# Also print the command, so this can be used to figure out what it is.
echo $argv[1]
return 1
end
return 0
end
function __fish_enqs_jail_using_subcommand
set -l cmd (__fish_enqs_jail_needs_command)
test -z "$cmd"
and return 1
contains -- $cmd[1] $argv
end
complete -c enqs-jail -n "__fish_enqs_jail_needs_command" -s h -l help -d 'Print help (see more with \'--help\')'
complete -c enqs-jail -n "__fish_enqs_jail_needs_command" -s V -l version -d 'Print version'
complete -c enqs-jail -n "__fish_enqs_jail_needs_command" -f -a "register" -d 'Register a directory as a jail'
complete -c enqs-jail -n "__fish_enqs_jail_needs_command" -f -a "unregister" -d 'Remove a registration'
complete -c enqs-jail -n "__fish_enqs_jail_needs_command" -f -a "list" -d 'Show the registered jails'
complete -c enqs-jail -n "__fish_enqs_jail_needs_command" -f -a "show" -d 'Show the settings a jail would run under'
complete -c enqs-jail -n "__fish_enqs_jail_needs_command" -f -a "check" -d 'Check the prerequisites'
complete -c enqs-jail -n "__fish_enqs_jail_needs_command" -f -a "allow" -d 'Re-open one path inside a jail'
complete -c enqs-jail -n "__fish_enqs_jail_needs_command" -f -a "escape" -d 'Let one command run outside the sandbox, leaving the jail'
complete -c enqs-jail -n "__fish_enqs_jail_needs_command" -f -a "revoke" -d 'Take a grant back'
complete -c enqs-jail -n "__fish_enqs_jail_needs_command" -f -a "grants" -d 'Show the exceptions in force for a jail'
complete -c enqs-jail -n "__fish_enqs_jail_needs_command" -f -a "completions" -d 'Print a tab completion script for a shell'
complete -c enqs-jail -n "__fish_enqs_jail_needs_command" -f -a "run" -d 'Start a session in a registered jail'
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand register" -l name -d 'The name of the jail; the directory name by default' -r
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand register" -l toolchain -d 'Toolchain whose caches stay readable; detected from the project when not given' -r
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand register" -l deny-read -d 'Path hidden inside the jail; replaces the default list' -r
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand register" -l allow-read -d 'Path that stays readable inside the jail (repeatable)' -r
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand register" -l allow-write -d 'Path that stays writable inside the jail (repeatable)' -r
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand register" -l add-dir -d 'Additional working directory inside the jail (repeatable)' -r
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand register" -l claude-config-dir -d 'Claude profile the session runs under, e.g. ~/.claude-work' -r
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand register" -l no-git -d 'Do not release the git configuration'
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand register" -l no-default-deny -d 'Do not use the default deny list'
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand register" -l force -d 'Overwrite an existing registration of this name'
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand register" -s h -l help -d 'Print help'
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand unregister" -s h -l help -d 'Print help'
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand list" -s h -l help -d 'Print help'
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand show" -s h -l help -d 'Print help'
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand check" -s h -l help -d 'Print help'
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand allow" -l for -d 'How long it should last, e.g. 30m, 2h, 7d' -r
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand allow" -l reason -d 'Why it was needed, kept with the grant' -r
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand allow" -l jail -d 'The jail; the current directory when left out' -r
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand allow" -l write -d 'Make it writable as well as readable'
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand allow" -l once -d 'Only for the next session'
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand allow" -s h -l help -d 'Print help'
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand escape" -l for -d 'How long it should last, e.g. 30m, 2h, 7d' -r
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand escape" -l reason -d 'Why it was needed, kept with the grant' -r
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand escape" -l jail -d 'The jail; the current directory when left out' -r
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand escape" -l once -d 'Only for the next session'
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand escape" -s h -l help -d 'Print help'
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand revoke" -l jail -d 'The jail; the current directory when left out' -r
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand revoke" -s h -l help -d 'Print help'
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand grants" -s h -l help -d 'Print help'
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand completions" -s h -l help -d 'Print help'
complete -c enqs-jail -n "__fish_enqs_jail_using_subcommand run" -s h -l help -d 'Print help'
complete --keep-order --exclusive --command enqs-jail --arguments "(COMPLETE=fish enqs-jail -- (commandline --current-process --tokenize --cut-at-cursor) (commandline --current-token))"
+42 -19
View File
@@ -11,10 +11,14 @@ import "root:/services"
//
// TYPING is always typing. Navigation lives on the arrows and on Ctrl+J/K so
// that nothing you can type is ever stolen from you — except in select mode,
// which you enter deliberately (the first arrow press does it) and which hands
// h/j/k/l over to navigation until you press Escape or Backspace. That is the
// compromise the vim keys need: a launcher whose input eats `j` is a launcher
// you cannot use to find Jellyfin.
// which hands h/j/k/l over to navigation. That is the compromise the vim keys
// need: a launcher whose input eats `j` is a launcher you cannot use to find
// Jellyfin.
//
// Select mode is vim's normal mode, and the modes change the way vim changes
// them: Escape leaves insert, `i` (or `a`) goes back into it without leaving
// an `i` behind, and Escape from select mode — with no insert left to leave —
// ends the prompt. Unbound keys in select mode are eaten, not typed.
//
// The other half of the grammar is the argument. Type a URL and the list turns
// into "open this with…", already sorted so the system default is row zero —
@@ -27,7 +31,10 @@ PanelWindow {
required property var modelData
screen: modelData
// Only the screen that had focus when the launcher was asked for shows it;
// the other copies stay dormant so the query is never typed into thin air.
readonly property bool open: Actions.launcherOpen
&& Actions.launcherScreen === modelData.name
visible: root.open || closeAnim.running
WlrLayershell.layer: WlrLayer.Overlay
@@ -403,14 +410,14 @@ PanelWindow {
font.letterSpacing: 3
renderType: Text.NativeRendering
text: root.selectMode
? "H J K L MOVE L PIN ESC TYPE"
? "J K MOVE L PIN H UNPIN i TYPE ESC QUIT"
: root.mode === "dmenu"
? "⏎ CHOOSE ESC CANCEL ↑↓ SELECT"
? "⏎ CHOOSE ESC SELECT ↑↓ MOVE"
: root.mode === "clip"
? "⏎ COPY ESC BACK ↑↓ SELECT"
? "⏎ COPY ESC SELECT ↑↓ MOVE"
: root.pinned
? "⏎ OPEN ESC UNPIN ↑↓ PICK"
: "TAB PIN > SHELL = CALC : CLIPBOARD"
? "⏎ OPEN ESC SELECT ↑↓ PICK"
: "ESC SELECT TAB PIN > SHELL = CALC : CLIP"
}
}
}
@@ -422,16 +429,23 @@ PanelWindow {
const ctrl = (event.modifiers & Qt.ControlModifier) !== 0;
// Escape peels one layer at a time: select mode, then the pin, then
// the launcher. Nothing about it is ever a surprise.
// Escape is the mode key, and it means what it means in vim: leave
// insert. From select mode there is nothing left to leave but the
// launcher itself, so the second press ends the prompt.
if (event.key === Qt.Key_Escape) {
if (root.selectMode) root.selectMode = false;
else if (root.pinned) root.unpin();
if (!root.selectMode && root.results.length > 0) root.selectMode = true;
else Actions.closeLauncher();
event.accepted = true;
return;
}
// …and Ctrl+C still walks out in one press, from wherever you are.
if (ctrl && event.key === Qt.Key_C) {
Actions.closeLauncher();
event.accepted = true;
return;
}
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
root.activate();
event.accepted = true;
@@ -446,7 +460,6 @@ PanelWindow {
if (event.key === Qt.Key_Down || (ctrl && event.key === Qt.Key_J)
|| (ctrl && event.key === Qt.Key_N)) {
root.selectMode = true;
root.move(1);
event.accepted = true;
return;
@@ -454,7 +467,6 @@ PanelWindow {
if (event.key === Qt.Key_Up || (ctrl && event.key === Qt.Key_K)
|| (ctrl && event.key === Qt.Key_P)) {
root.selectMode = true;
root.move(-1);
event.accepted = true;
return;
@@ -468,14 +480,23 @@ PanelWindow {
if (!root.selectMode) return;
// Select mode. The letters navigate; anything else drops you back into
// the input, having typed nothing, so a mistyped `d` costs one press
// rather than a mangled query.
// Select mode. The letters are commands, not text: `i` and `a` go back
// to insert without leaving an `i` behind, and everything unclaimed is
// swallowed rather than typed, so a stray `d` costs nothing at all.
switch (event.key) {
case Qt.Key_J: root.move(1); event.accepted = true; return;
case Qt.Key_K: root.move(-1); event.accepted = true; return;
case Qt.Key_L: root.pin(); event.accepted = true; return;
case Qt.Key_H: root.unpin(); event.accepted = true; return;
case Qt.Key_I:
case Qt.Key_A:
root.selectMode = false;
input.forceActiveFocus();
// `a` appends, `i` leaves the cursor where it was — the same
// distinction, for the same reason.
if (event.key === Qt.Key_A) input.cursorPosition = input.text.length;
event.accepted = true;
return;
case Qt.Key_G:
root.selected = (event.modifiers & Qt.ShiftModifier)
? root.results.length - 1 : 0;
@@ -484,11 +505,13 @@ PanelWindow {
return;
case Qt.Key_Backspace:
root.selectMode = false;
input.forceActiveFocus();
event.accepted = true;
return;
}
if (event.text !== "") root.selectMode = false;
// Anything else in select mode is a command nobody bound. Eat it.
if (event.text !== "") event.accepted = true;
}
// ------------------------------------------------------------- animation
+24 -14
View File
@@ -3,6 +3,7 @@ pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Io
import Quickshell.Hyprland
import "root:/services"
// Shell-wide UI state and the handful of external commands the shell fires.
@@ -22,14 +23,29 @@ Singleton {
// "https://…"` is an open-with dialog for anything that can run a command.
property string launcherSeed: ""
// A launcher window exists on every screen, but only one of them is being
// typed at. Latch the focused monitor at open time so the window appears
// there alone — latched rather than live, because the launcher itself takes
// keyboard focus and because a window should not hop mid-query.
property string launcherScreen: ""
signal osdRequested(string kind)
function togglePowerMenu() { root.powerMenuOpen = !root.powerMenuOpen; }
function closePowerMenu() { root.powerMenuOpen = false; }
function lock() { root.powerMenuOpen = false; root.lockRequested = true; }
function focusedScreenName(): string {
return Hyprland.focusedMonitor?.name
?? Quickshell.screens[0]?.name
?? "";
}
function toggleLauncher() {
if (!root.launcherOpen) root.launcherSeed = "";
if (!root.launcherOpen) {
root.launcherSeed = "";
root.launcherScreen = root.focusedScreenName();
}
root.launcherOpen = !root.launcherOpen;
}
function closeLauncher() { root.launcherOpen = false; }
@@ -38,31 +54,25 @@ Singleton {
function dmenuLauncher(inPath: string, outPath: string, prompt: string) {
Apps.beginDmenu(inPath, outPath, prompt);
root.launcherSeed = "";
root.launcherScreen = root.focusedScreenName();
root.launcherOpen = false;
root.launcherOpen = true;
}
function promptLauncher(seed: string) {
root.launcherSeed = seed;
root.launcherScreen = root.focusedScreenName();
root.launcherOpen = false;
root.launcherOpen = true;
}
// ------------------------------------------------------------- commands
// Each slot gets its own Process so a slow one cannot cancel another.
Process { id: slotA }
Process { id: slotB }
Process { id: slotC }
property int _slot: 0
// Detached, because nothing here is ever read back. Rotating a fixed set of
// `Process` slots only moves the collision: `uwsm app` lives as long as the
// app it started, so the fourth launch reclaims the first slot and kills the
// app still holding it — and a shell reload kills every one of them at once.
function run(argv: var) {
const slots = [slotA, slotB, slotC];
const p = slots[root._slot % slots.length];
root._slot++;
p.running = false;
p.command = argv;
p.running = true;
Quickshell.execDetached(argv);
}
function launch(app: string) {
+18 -11
View File
@@ -311,19 +311,19 @@ Singleton {
root._remember(item.key);
if (arg === "") {
proc.exec(["uwsm", "app", "--", item.key]);
Quickshell.execDetached(["uwsm", "app", "--", item.key]);
return;
}
if (root.fieldRe.test(item.exec || "")) {
proc.exec(["uwsm", "app", "--", item.key, arg]);
Quickshell.execDetached(["uwsm", "app", "--", item.key, arg]);
return;
}
const argv = root._tokenize(item.exec || "")
.filter(t => !root.anyFieldRe.test(t));
if (argv.length === 0) {
proc.exec(["uwsm", "app", "--", item.key]);
Quickshell.execDetached(["uwsm", "app", "--", item.key]);
return;
}
argv.push(arg);
@@ -333,7 +333,7 @@ Singleton {
const name = item.key.replace(".desktop", "").replace(/[^a-zA-Z0-9_-]/g, "-");
const head = ["uwsm", "app", "-a", name];
if (item.terminal) head.push("-T");
proc.exec(head.concat(["--"]).concat(argv));
Quickshell.execDetached(head.concat(["--"]).concat(argv));
}
// Exec lines are shell-ish but not shell: the spec allows double quotes and
@@ -367,17 +367,24 @@ Singleton {
function runShell(line: string, inTerminal: bool): void {
if (line.trim() === "") return;
if (inTerminal) proc.exec(["uwsm", "app", "-T", "--", "sh", "-c", line]);
else proc.exec(["uwsm", "app", "--", "sh", "-c", line]);
if (inTerminal) Quickshell.execDetached(["uwsm", "app", "-T", "--", "sh", "-c", line]);
else Quickshell.execDetached(["uwsm", "app", "--", "sh", "-c", line]);
}
function copy(text: string): void {
proc.exec(["wl-copy", "--", text]);
Quickshell.execDetached(["wl-copy", "--", text]);
}
// Fire-and-forget. Each call replaces the last, which is fine because uwsm
// has already handed the app off to systemd by the time it exits.
Process { id: proc }
// Everything above spawns through `Quickshell.execDetached` rather than a
// `Process`, and it has to. `uwsm app` does not exit once the scope is up —
// it stays on as the scope's main process for as long as the app lives. A
// shared `Process` therefore never goes idle, so the next `exec()` kills the
// previous uwsm, systemd tears down the scope with it, and launching the
// second app closes the first. Shell reload did the same thing to every app
// at once, since `manageLifetime` kills the child when the object goes away.
//
// A detached spawn is owned by nobody here, which is exactly right: once
// uwsm has the scope, the shell has no further business in that lifetime.
// ----------------------------------------------------------------- dmenu
// The launcher can stand in for `fuzzel --dmenu`, which is what lets fuzzel
@@ -494,7 +501,7 @@ Singleton {
// wl-copy without being round-tripped through a QML string.
function pasteClip(item: var): void {
if (!/^[0-9]+$/.test(item.clipId)) return;
proc.exec(["sh", "-c", "cliphist decode " + item.clipId + " | wl-copy"]);
Quickshell.execDetached(["sh", "-c", "cliphist decode " + item.clipId + " | wl-copy"]);
}
function searchClips(term: string): var {