Repository navigation
feat(keys): run shell commands from shortcuts with spawn-sh - #298
Merged
Merged
Conversation
A spawn-sh binding runs the rest of its line with /bin/sh -c, as in Niri, so users can script their own commands with the defi CLI. The PATH gains the folder holding defi and the Homebrew prefixes, since launchd starts the daemon with a bare one.
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — Adds explicitly configured shell-command shortcuts, with documented permission inheritance and no default binding. IPC requests are blocked, and head-revision testing demonstrates both shortcut execution and socket refusal. You can add or adjust custom eligibility rules. Learn more. |
Any local process can reach Defi's socket, and a spawned shell inherits Defi's Accessibility and Screen Recording grants, so only shortcuts may run spawn-sh.
Owner
Author
|
Fixed in 871027a: the socket now refuses |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A
[keys]binding now runs a shell command line, like Niri'sspawn-sh, so users can script their own commands on top of thedefiCLI. Asked for on Reddit to port a Niri "swap columns between two monitors" script.spawn-sh, because any local process can reach it and the shell inherits Defi's Accessibility and Screen Recording grants (raised by Macroscope).CONFIGURATION.md: command row plus a short Scripts section, including that scripts share Defi's Accessibility and Screen Recording permissions.Evidence
Real key press, in the defi-e2e VM (staged build of 871027a, scratch config
"ctrl-alt-home" = "spawn-sh …", HID key event):Earlier, before the socket refusal, proved with
make verify, parser/PATH tests, and the installed build (commit 69628b2, same designated requirement, onedefi-daemon):spawn-sh→unknownCommand("spawn-sh").After:
ModelTestsparses" spawn-sh defi focus-column left | tee \"a b\" "to.spawnShell("defi focus-column left | tee \"a b\"");SpawnShellTestschecks the PATH order and deduplication.SpawnShellTests.socketClientsCannotSpawnShellscovers the refusal. Not covered: the two-display lane (nothing display-specific here).Merge Danger
Door: two-way
New opt-in command; nothing runs unless a user binds it.
Blast Radius: small
Commands run with Defi's TCC grants, documented, and only from the user's own shortcuts. Config with
spawn-shfails to load on older builds with an unknown-command error.Reviewed with review-loop: 1 round with claude-opus-5-5 (medium). Verdict: approved
Note
Add
spawn-shcommand to run shell scripts from shortcutsspawn-sh <command line>launch the script via/bin/sh -cin the home directory, without waiting for it to finish. Parsed in CommandParser.swift and launched by the newspawnShellhelper in DaemonCommands.swiftspawnSearchPathhelperspawn-sh; the newrefusedOverIPCcheck in DaemonCommands.swift returns a failure response before dispatch.spawnShellas a no-op for layout and native-fullscreen classification; the cheatsheet shows a "Run" labelspawn-shvia IPC now returns a failure response instead of dispatching — check the earlyrefusedOverIPCcheck in the IPC event handlerMacroscope summarized 871027a.