Improve actionable notification wrapper

This commit is contained in:
David Heinemeier Hansson
2026-05-25 23:51:48 +02:00
parent 322d1bc30d
commit af5e918dd5
10 changed files with 107 additions and 26 deletions
+3 -2
View File
@@ -245,8 +245,9 @@ stop_screenrecording() {
ffmpeg -y -i "$filename" -ss 00:00:00.1 -vframes 1 -q:v 2 "$preview" -loglevel quiet 2>/dev/null
(
ACTION=$(notify-send -a omarchy-action "Screen recording saved" "Open with Super + Alt + , (or click this)" -t 10000 --hint="string:image-path:${preview:-$filename}" -A "default=open")
[[ $ACTION == "default" ]] && mpv "$filename"
if [[ -n $(omarchy-notification-send "Screen recording saved" "Open with Super + Alt + , (or click this)" -t 10000 --image "${preview:-$filename}" -a) ]]; then
mpv "$filename"
fi
rm -f "$preview"
) &
fi
+3 -2
View File
@@ -133,8 +133,9 @@ case "$PROCESSING" in
wl-copy --type image/png <"$FILEPATH"
(
ACTION=$(notify-send -a omarchy-action "Screenshot saved to clipboard and file" "Edit with Super + Alt + , (or click this)" -t 10000 --hint="string:image-path:$FILEPATH" -A "default=edit")
[[ $ACTION == "default" ]] && open_editor "$FILEPATH"
if [[ -n $(omarchy-notification-send "Screenshot saved to clipboard and file" "Edit with Super + Alt + , (or click this)" -t 10000 --image "$FILEPATH" -a) ]]; then
open_editor "$FILEPATH"
fi
) >/dev/null 2>&1 &
;;
copy)
+44 -9
View File
@@ -1,7 +1,7 @@
#!/bin/bash
# omarchy:summary=Send an Omarchy desktop notification
# omarchy:args=[-g <glyph>] [-u <low|normal|critical>] <headline> [description] [notify-send options]
# omarchy:args=[-a] [--app-name <app-name>] [-g <glyph>] [-u <low|normal|critical>] [--image <path-or-uri>] <headline> [description] [notify-send options]
# omarchy:examples=omarchy notification send "Reminder" "5 minutes are up" -g 󰢌
set -euo pipefail
@@ -10,7 +10,11 @@ headline=""
description=""
glyph=
urgency="low"
app_name="omarchy-action"
image=
click_action=0
args=()
parsed_option_args=0
parse_omarchy_option() {
case $1 in
@@ -20,6 +24,7 @@ parse_omarchy_option() {
exit 1
fi
glyph=$2
parsed_option_args=2
return 0
;;
-u | --urgency)
@@ -28,6 +33,30 @@ parse_omarchy_option() {
exit 1
fi
urgency="$2"
parsed_option_args=2
return 0
;;
--app-name)
if (($# < 2)); then
echo "Missing value for $1" >&2
exit 1
fi
app_name=$2
parsed_option_args=2
return 0
;;
--image)
if (($# < 2)); then
echo "Missing value for $1" >&2
exit 1
fi
image=$2
parsed_option_args=2
return 0
;;
-a | --action)
click_action=1
parsed_option_args=1
return 0
;;
esac
@@ -37,14 +66,14 @@ parse_omarchy_option() {
while (($# > 0)); do
if parse_omarchy_option "$@"; then
shift 2
shift "$parsed_option_args"
else
break
fi
done
if (($# < 1)); then
echo "Usage: omarchy-notification-send [-g <glyph>] [-u <low|normal|critical>] <headline> [description] [notify-send options]"
echo "Usage: omarchy-notification-send [-a] [--app-name <app-name>] [-g <glyph>] [-u <low|normal|critical>] [--image <path-or-uri>] <headline> [description] [notify-send options]"
exit 1
fi
@@ -58,20 +87,26 @@ fi
while (($# > 0)); do
if parse_omarchy_option "$@"; then
shift 2
shift "$parsed_option_args"
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")
# Tag as a user-action toast so it pops through DND.
args+=("-a" "$app_name" "-u" "$urgency")
# Keep Omarchy action toasts compact by rendering glyphs inline instead of
# forcing the notification card's icon slot.
if [[ -n $glyph ]]; then
headline="$glyph $headline"
args+=("--hint=string:omarchy-glyph:$glyph")
fi
if [[ -n $image ]]; then
args+=("--hint=string:image-path:$image")
fi
if ((click_action)); then
args+=("-A" "default=default")
fi
if [[ -n $description ]]; then