diff --git a/bin/omarchy-capture-screenrecording b/bin/omarchy-capture-screenrecording index 5532b4aa..becd5fdb 100755 --- a/bin/omarchy-capture-screenrecording +++ b/bin/omarchy-capture-screenrecording @@ -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() { diff --git a/bin/omarchy-notification-dismiss b/bin/omarchy-notification-dismiss index 20651510..91e8b0d0 100755 --- a/bin/omarchy-notification-dismiss +++ b/bin/omarchy-notification-dismiss @@ -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" diff --git a/bin/omarchy-osd b/bin/omarchy-osd index ed3ef72a..95af756f 100755 --- a/bin/omarchy-osd +++ b/bin/omarchy-osd @@ -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" diff --git a/bin/omarchy-shell b/bin/omarchy-shell index 5b71cc30..b73e6188 100755 --- a/bin/omarchy-shell +++ b/bin/omarchy-shell @@ -1,19 +1,30 @@ #!/bin/bash # omarchy:summary=Send an IPC call to the running Omarchy shell -# omarchy:args= [args...] +# omarchy:args=[-q] [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 < [args...] +Usage: omarchy-shell [-q] [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 [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" "$@" diff --git a/bin/omarchy-theme-bg-set b/bin/omarchy-theme-bg-set index f31d554b..4ecd069b 100755 --- a/bin/omarchy-theme-bg-set +++ b/bin/omarchy-theme-bg-set @@ -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" diff --git a/bin/omarchy-toggle-idle b/bin/omarchy-toggle-idle index 7e071018..5f6c9beb 100755 --- a/bin/omarchy-toggle-idle +++ b/bin/omarchy-toggle-idle @@ -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 diff --git a/bin/omarchy-toggle-notification-silencing b/bin/omarchy-toggle-notification-silencing index c3787a18..adf608c0 100755 --- a/bin/omarchy-toggle-notification-silencing +++ b/bin/omarchy-toggle-notification-silencing @@ -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 diff --git a/bin/omarchy-update-available-reset b/bin/omarchy-update-available-reset index 5c8cf30e..a72eb219 100755 --- a/bin/omarchy-update-available-reset +++ b/bin/omarchy-update-available-reset @@ -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