diff options
| author | Léana 江 <leana.jiang+git@icloud.com> | 2026-04-25 23:16:28 +0200 |
|---|---|---|
| committer | Léana 江 <leana.jiang+git@icloud.com> | 2026-04-25 23:27:35 +0200 |
| commit | 10bb1305eac8cd2a3b5d6bcd53982adb685f0c73 (patch) | |
| tree | 5fe27e769c4d08099d5341d6d50e6869508ebd1d /etc | |
| parent | 34d6b33443f3962bff5dd6e41ec8444c9a0c96e6 (diff) | |
| download | xmobar-10bb1305eac8cd2a3b5d6bcd53982adb685f0c73.tar.gz xmobar-10bb1305eac8cd2a3b5d6bcd53982adb685f0c73.tar.bz2 | |
add notify-once script and documentation
Diffstat (limited to 'etc')
| -rw-r--r-- | etc/notify-once.sh | 31 |
1 files changed, 31 insertions, 0 deletions
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 <name> [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" |
