rc/lib/utils.sh

25 lines
527 B
Bash

die() {
# Use notify-send to send errors when not in a terminal
# [ -t 0 ] only works outside of pipes
[ -t 0 ] || notify-send "$@" && >&2 echo "$@"
exit 1
}
# Output error to stderr and to graphical notification
notify_err() {
tee /dev/fd/2 | xargs -r -n1 -d "\n" notify-send
}
assert_exists() {
for c in $@; do
which "$c" > /dev/null 2>&1 || die "$c doesn't appear to be installed"
done
}
check_exists() {
for c in $@; do
which "$c" > /dev/null 2>&1 || return 1
done
}