dotfiles/lib/lib.sh
2023-10-14 22:38:06 +02:00

32 lines
525 B
Bash

#!/bin/sh
. ./sync.conf || . ../sync.conf
DRY_RUN=${DRY_RUN:-no}
bool() {
case "$1" in
1|true|yes|on|TRUE|YES|ON) return 0 ;;
*) return 1 ;;
esac
}
run() {
# Check if command starts with NO_RUN ($*) and remove it
if echo "$*" | grep -q "^NO_RUN"; then
return 0
fi
if bool "$DRY_RUN"; then
echo "DRY: + $*"
else
echo "+ $*"
"$@"
fi
}
is_graphical() {
command -v $PREF_TERM > /dev/null && return 0 || return 1
}
command -v $SYS_SUDO > /dev/null || SYS_SUDO="NO_RUN"