From 10bb1305eac8cd2a3b5d6bcd53982adb685f0c73 Mon Sep 17 00:00:00 2001 From: Léana 江 Date: Sat, 25 Apr 2026 23:16:28 +0200 Subject: add notify-once script and documentation --- etc/notify-once.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 etc/notify-once.sh (limited to 'etc') diff --git a/etc/notify-once.sh b/etc/notify-once.sh new file mode 100644 index 0000000..1c46401 --- /dev/null +++ b/etc/notify-once.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +set -euo pipefail + +help() { + echo "notify-send: send deduplicated notifications" + echo "Usage: notify-once [ARGS]" + echo " ARGS are arguments passed directly to notify-send" +} + +if [ $# -lt 1 ]; then + echo "Should get at least one argument, a name" >&2 + help + exit 1 +fi +APPNAME="$1" +shift + +ID_PATH="/tmp/notify-state-$APPNAME" + +if [ -e "$ID_PATH" ]; then + # Exists, replace + ID=$(cat "$ID_PATH") + ID=$(notify-send -r "$ID" -p "$@") +else + # Doesn't exist, create + ID=$(notify-send -p "$@") +fi + +# Store new ID +echo "$ID" >"$ID_PATH" -- cgit v1.2.3