24 lines
524 B
Bash
24 lines
524 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 -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
|
|
}
|
|
|