From 7922604282e94f2a59c63a949370a71226b6a65c Mon Sep 17 00:00:00 2001 From: boredpasta Date: Sun, 31 Dec 2023 03:19:49 +0200 Subject: notify-replace: cleanup --- notify-replace | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'notify-replace') 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 -- cgit v1.2.3