dotfiles/sh/.local/bin/exist
Marty Oehme 145548c01a
Change ifinstalled script to exist
Renamed ifinstalled to exist, moved it into base shell module. It can be
called with just a command name to check for, or with an additional
libnotify urgency level (low, normal, critical).

If called with an urgency as the second argument, the user will be
notified of the missing command with the corresponding urgency.
2020-02-08 20:23:30 +01:00

18 lines
478 B
Bash
Executable file

#!/usr/bin/env sh
# check for existing implementations
# If $1 command is not available, error code
# If $2 is low, normal, urgent, also notify the user. (loud-mode)
if command -v "$1" >/dev/null; then
exit 0
else
if [ -n "$2" ]; then
if command -v notify-send >/dev/null; then
notify-send "📦 $1" --urgency="$2" "must be installed for this function."
else
printf "%s: 📦 %s must be installed for this function.\n" "$2" "$1"
fi
fi
exit 1
fi