Files
arthur-os/bin/omarchy-notification-send
T

84 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
# omarchy:summary=Send a desktop notification with Omarchy glyph and body spacing
# omarchy:args=<headline> [description] [-g <glyph>] [-u <low|normal|critical>] [notify-send options]
# omarchy:examples=omarchy notification send "Reminder" "5 minutes are up" -g 󰔛 -u critical
set -euo pipefail
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 <glyph>] [-u <low|normal|critical>] <headline> [description] [notify-send options]"
exit 1
fi
headline=$1
shift
if (($# > 0)) && [[ $1 != -* ]]; then
description=$1
shift
fi
while (($# > 0)); do
if parse_omarchy_option "$@"; then
shift 2
else
args+=("$1")
shift
fi
done
# Tag as a user-action toast so it pops through DND. See dnd-fix-plan.md.
args+=("-a" "omarchy-action" "-u" "$urgency")
# Send the glyph both as a custom hint and in a summary prefix.
# Quickshell strips the prefix back into the icon slot; other notification
# daemons still get the familiar glyph + spacing presentation.
if [[ -n $glyph ]]; then
args+=("--hint=string:omarchy-glyph:$glyph")
headline="$glyph $headline"
fi
if [[ -n $description ]]; then
notify-send "${args[@]}" "$headline" "$description"
else
notify-send "${args[@]}" "$headline"
fi