2020-12-22 22:09:06 +00:00
|
|
|
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() {
|
2020-12-31 15:05:08 +00:00
|
|
|
tee /dev/fd/2 | xargs -r -n1 -d "\n" notify-send
|
2020-12-22 22:09:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|