diff options
author | boredpasta <boredpasta@tutanota.com> | 2023-12-31 03:19:49 +0200 |
---|---|---|
committer | boredpasta <boredpasta@tutanota.com> | 2023-12-31 03:19:49 +0200 |
commit | 7922604282e94f2a59c63a949370a71226b6a65c (patch) | |
tree | c5d593c754764b98754b670507bfaab7a44f82fd | |
parent | a66c62baa08d6819aa08016da1cd3c16e8731153 (diff) |
notify-replace: cleanup
-rwxr-xr-x | notify-replace | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/notify-replace b/notify-replace index 8e6951a..b083565 100755 --- a/notify-replace +++ b/notify-replace @@ -1,24 +1,22 @@ -#!/bin/sh +#!/bin/sh -u # Sends, remembers, and replaces notifications based on program name that's # passed as first argument to script. Uses notify-send. # Non-POSIX features used: flock(1) # TODO: consider replacing flock(1) with a POSIX-complaint alternative -xdg_config_home="${XDG_CONFIG_HOME:-$HOME/.config}" -config_dir="$xdg_config_home/notify-replace" +config_dir="${XDG_CONFIG_HOME:-$HOME/.config}/notify-replace" [ -d "$config_dir" ] || mkdir -p "$config_dir" -if [ -z "$1" ]; then +if [ -z "${1:-}" ]; then # TODO: check if there's a better way to acquire name of currently # executing script # TODO: get rid of subshell - program=$(basename $0) - # TODO: shorten line - echo "$program: Need to provide notification id filename as first argument" 1>&2 + echo "$(basenme "$0"): Need to provide notification id filename as first \ + argument" 1>&2 exit 1 fi -lockdir="$config_dir/notify-replace.lock" -notification_file="$config_dir/$1" +lockdir="${config_dir}/notify-replace.lock" +notification_file="${config_dir}/${1}" shift # Exit if lock is in use. A lock is used to prevent multiple invocations |