From 8788dd2eb27dcb30cd5f2cf0134f38025d45e400 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 10 May 2026 16:44:09 +0200 Subject: [PATCH] Fix arg order --- bin/omarchy-notification-send | 65 ++++++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 20 deletions(-) diff --git a/bin/omarchy-notification-send b/bin/omarchy-notification-send index 5bdf5847..becb6c93 100755 --- a/bin/omarchy-notification-send +++ b/bin/omarchy-notification-send @@ -6,16 +6,49 @@ set -euo pipefail -if (($# < 1)); then - echo "Usage: omarchy-notification-send [description] [-g ] [-u ] [notify-send options]" - exit 1 -fi - -headline=$1 +headline="" description="" glyph="" urgency="low" args=() + +parse_omarchy_option() { + case $1 in + -g | --glyph) + if (($# < 2)); then + echo "Missing value for $1" >&2 + exit 1 + fi + glyph="$2" + return 0 + ;; + -u | --urgency) + if (($# < 2)); then + echo "Missing value for $1" >&2 + exit 1 + fi + urgency="$2" + return 0 + ;; + esac + + return 1 +} + +while (($# > 0)); do + if parse_omarchy_option "$@"; then + shift 2 + else + break + fi +done + +if (($# < 1)); then + echo "Usage: omarchy-notification-send [-g ] [-u ] [description] [notify-send options]" + exit 1 +fi + +headline=$1 shift if (($# > 0)) && [[ $1 != -* ]]; then @@ -24,20 +57,12 @@ if (($# > 0)) && [[ $1 != -* ]]; then fi while (($# > 0)); do - case $1 in - -g|--glyph) - glyph="$2" - shift 2 - ;; - -u|--urgency) - urgency="$2" - shift 2 - ;; - *) - args+=("$1") - shift - ;; - esac + if parse_omarchy_option "$@"; then + shift 2 + else + args+=("$1") + shift + fi done summary="$glyph $headline"