Move merge command decision to common.sh and check whether DISPLAY is set

This commit is contained in:
har0ke 2024-10-31 19:49:01 +01:00
parent 2beca9ef56
commit 64f979c300
3 changed files with 12 additions and 7 deletions

View File

@ -6,6 +6,15 @@ DEV=0
EXTRA=0
WORKSTATION=0
if [[ -n "$DISPLAY" ]] && command -v meld &> /dev/null;
then
merge_cmd=(meld)
else
merge_cmd=(vim -d)
fi
if [[ "$#" -eq 0 ]]; then
ALL=1
fi
@ -43,6 +52,7 @@ while true; do
done
if [ "${ALL}" -eq 1 ]; then
CORE=1
WORKSTATION=1
EXTRA=1
DEV=1

View File

@ -105,12 +105,7 @@ function install() {
fi
if [ -e "${dst}" ]; then
if command -v meld &> /dev/null
then
run_as_user "${user}" meld "${src}" "${dst}"
else
run_as_user "${user}" vim -d "${src}" "${dst}"
fi
run_as_user "${user}" "${merge_cmd[@]}" "${src}" "${dst}"
fi
backup_file "${dst}"
echo "${dst} will now be linked."

View File

@ -5,6 +5,6 @@ set -euo pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
if ! diff "${SCRIPT_DIR}/etc/pam.d/login" /etc/pam.d/login &> /dev/null; then
sudo meld "${SCRIPT_DIR}/etc/pam.d/login" /etc/pam.d/login
sudo "${merge_cmd[@]}" "${SCRIPT_DIR}/etc/pam.d/login" /etc/pam.d/login
fi