Introduce omarchy-shell -q for fire and forget

This commit is contained in:
David Heinemeier Hansson
2026-05-20 14:24:19 +02:00
parent ed3320cb8d
commit c87bfb8da8
8 changed files with 34 additions and 31 deletions
+1 -1
View File
@@ -255,7 +255,7 @@ stop_screenrecording() {
}
toggle_screenrecording_indicator() {
omarchy-shell bar refreshScreenRecording >/dev/null 2>&1 || true
omarchy-shell -q bar refreshScreenRecording
}
screenrecording_active() {
+1 -1
View File
@@ -8,4 +8,4 @@ if (($# == 0)); then
exit 1
fi
omarchy-shell notifications dismiss "$1" >/dev/null 2>&1 || true
omarchy-shell -q notifications dismiss "$1"
+1 -1
View File
@@ -34,4 +34,4 @@ payload=$(jq -cn \
--arg max "$max" \
'{icon:$icon,message:$message,value:$value,progressText:$progressText,max:$max}')
omarchy-shell osd show "$payload" >/dev/null 2>&1 || true
omarchy-shell -q osd show "$payload"
+26 -7
View File
@@ -1,19 +1,30 @@
#!/bin/bash
# omarchy:summary=Send an IPC call to the running Omarchy shell
# omarchy:args=<target> <method> [args...]
# omarchy:args=[-q] <target> <method> [args...]
# omarchy:examples=omarchy shell shell ping | omarchy-shell menu toggle root
QUIET=0
if [[ ${1:-} == "-q" ]]; then
QUIET=1
shift
fi
if [[ $# -eq 0 || $1 == "-h" || $1 == "--help" ]]; then
cat <<USAGE
Usage: omarchy-shell <target> <method> [args...]
Usage: omarchy-shell [-q] <target> <method> [args...]
Forwards an IPC call to the running Omarchy shell. The shell is expected
to already be running; this command does not start it.
Options:
-q Quiet best-effort mode. Suppress output and return success even when
the shell, target, method, or arguments are unavailable.
Examples:
omarchy-shell shell ping
omarchy-shell shell summon omarchy.settings "{}"
omarchy-shell -q bar refreshIndicators
omarchy-shell shell listPlugins
omarchy-shell menu toggle root
USAGE
@@ -21,11 +32,13 @@ USAGE
fi
if (( $# < 2 )); then
(( QUIET )) && exit 0
echo "Usage: omarchy-shell <target> <method> [args...]" >&2
exit 1
fi
if [[ -z ${OMARCHY_PATH:-} ]]; then
(( QUIET )) && exit 0
echo "OMARCHY_PATH is not set" >&2
exit 1
fi
@@ -36,6 +49,8 @@ if [[ $1 == "shell" && ( $2 == "summon" || $2 == "toggle" ) && $# -eq 3 ]]; then
set -- "$1" "$2" "$3" "{}"
fi
export OMARCHY_SHELL_QUIET="$QUIET"
perl -MCwd=abs_path -MEncode=encode,decode -MSocket -MIO::Handle \
-e '
binmode STDOUT, ":encoding(UTF-8)";
@@ -82,10 +97,12 @@ perl -MCwd=abs_path -MEncode=encode,decode -MSocket -MIO::Handle \
my $function = decode("UTF-8", shift @ARGV);
my @args = map { decode("UTF-8", $_) } @ARGV;
my $runtime_dir = $ENV{"XDG_RUNTIME_DIR"} || "/run/user/$<";
my $quiet = ($ENV{"OMARCHY_SHELL_QUIET"} || "") eq "1";
my $payload = chr(3) . qstring($target) . qstring($function) . pack("N", scalar @args) . join("", map { qstring($_) } @args);
my @candidates;
if (!defined $shell_qml) {
exit 0 if $quiet;
print STDERR "omarchy-shell config not found: $shell_qml_arg\n";
exit 1;
}
@@ -124,22 +141,24 @@ perl -MCwd=abs_path -MEncode=encode,decode -MSocket -MIO::Handle \
next unless length($response);
my $code = ord(substr($response, 0, 1));
if ($code == 5) {
exit 0 if $quiet;
print_success($response);
exit 0;
} elsif ($code == 2) {
print STDERR "Target not found.\n";
print STDERR "Target not found.\n" unless $quiet;
} elsif ($code == 3) {
print STDERR "Function not found.\n";
print STDERR "Function not found.\n" unless $quiet;
} elsif ($code == 4) {
print STDERR "Invalid arguments.\n";
print STDERR "Invalid arguments.\n" unless $quiet;
} else {
print STDERR "Unexpected IPC response: $code\n";
print STDERR "Unexpected IPC response: $code\n" unless $quiet;
}
exit 1;
exit($quiet ? 0 : 1);
}
close($client);
}
exit 0 if $quiet;
print STDERR "omarchy-shell is not running\n";
exit 1;
' "$SHELL_QML" "$@"
+1 -1
View File
@@ -22,4 +22,4 @@ ln -nsf "$BACKGROUND" "$CURRENT_BACKGROUND_LINK"
# Update the live shell background immediately when it is running. The
# background plugin also polls this symlink, but IPC avoids the visible delay.
omarchy-shell background set "$BACKGROUND" >/dev/null 2>&1 || true
omarchy-shell -q background set "$BACKGROUND"
+2 -18
View File
@@ -2,21 +2,5 @@
# omarchy:summary=Toggle idle behavior so the system either idles normally or stays awake
if ! state=$(omarchy-shell idle toggle); then
exit 1
fi
case $state in
enabled)
omarchy-notification-send -g "󰾪" "Idle behavior on" "System can now lock on idle"
;;
disabled)
omarchy-notification-send -g "󰅶" "Staying awake" "Idle behavior disabled"
;;
*)
echo "Unexpected idle state: $state" >&2
exit 1
;;
esac
omarchy-shell bar refreshIndicators >/dev/null 2>&1 || true
omarchy-shell idle toggle
omarchy-shell -q bar refreshIndicators
+1 -1
View File
@@ -3,4 +3,4 @@
# omarchy:summary=Toggle notification do-not-disturb mode
state=$(omarchy-shell notifications toggleDnd 2>/dev/null || echo "")
omarchy-shell bar refreshIndicators >/dev/null 2>&1 || true
omarchy-shell -q bar refreshIndicators
+1 -1
View File
@@ -2,5 +2,5 @@
# omarchy:summary=Ensure the status bar icon offering the available update is removed
omarchy-shell bar refreshUpdate >/dev/null 2>&1 || true
omarchy-shell -q bar refreshUpdate
exit 0