|
|
@ -12,6 +12,24 @@ smartdiff() { |
|
|
|
fi |
|
|
|
fi |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
resolvedifference() { |
|
|
|
|
|
|
|
userfile="$1" |
|
|
|
|
|
|
|
defaultfile="$2" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
( |
|
|
|
|
|
|
|
printf "\e[31mThe file \e[32m%s\e[31m differs\e[0m\n" "$userfile" |
|
|
|
|
|
|
|
smartdiff -ud "$userfile" "$defaultfile" |
|
|
|
|
|
|
|
) | less -RF |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf "\e[33mDo you want to apply the default? [y/N], or perhaps open an editor [e]?\e[0m " |
|
|
|
|
|
|
|
read -r reply < /dev/tty |
|
|
|
|
|
|
|
if [ "y" = "$reply" ]; then |
|
|
|
|
|
|
|
cp "$defaultfile" "$userfile" |
|
|
|
|
|
|
|
elif [ "e" = "$reply" ]; then |
|
|
|
|
|
|
|
$EDITOR "$userfile" "$defaultfile" |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
defaultconfig() { |
|
|
|
defaultconfig() { |
|
|
|
if [ ! -r "$2" ]; then |
|
|
|
if [ ! -r "$2" ]; then |
|
|
|
mkdir -p "$(dirname "$2")" |
|
|
|
mkdir -p "$(dirname "$2")" |
|
|
@ -19,17 +37,7 @@ defaultconfig() { |
|
|
|
chmod "$3" "$2" |
|
|
|
chmod "$3" "$2" |
|
|
|
else |
|
|
|
else |
|
|
|
if ! diff "$2" "$1" > /dev/null; then |
|
|
|
if ! diff "$2" "$1" > /dev/null; then |
|
|
|
( |
|
|
|
resolvedifference "$2" "$1" |
|
|
|
printf "\e[31mThe file \e[32m%s\e[31m differs\e[0m\n" "$2" |
|
|
|
|
|
|
|
smartdiff -ud "$2" "$1" |
|
|
|
|
|
|
|
) | less -RF |
|
|
|
|
|
|
|
printf "\e[33mDo you want to apply the default? [y/N], or perhaps open an editor [e]?\e[0m " |
|
|
|
|
|
|
|
read -r reply < /dev/tty |
|
|
|
|
|
|
|
if [ "y" = "$reply" ]; then |
|
|
|
|
|
|
|
cp "$1" "$2" |
|
|
|
|
|
|
|
elif [ "e" = "$reply" ]; then |
|
|
|
|
|
|
|
$EDITOR "$2" "$1" |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
fi |
|
|
|
fi |
|
|
|
fi |
|
|
|
fi |
|
|
|
} |
|
|
|
} |
|
|
@ -40,17 +48,7 @@ checkhooks() { |
|
|
|
defaulthook="/usr/share/sxmo/default_hooks/$(basename "$hook")" |
|
|
|
defaulthook="/usr/share/sxmo/default_hooks/$(basename "$hook")" |
|
|
|
if [ -f "$defaulthook" ]; then |
|
|
|
if [ -f "$defaulthook" ]; then |
|
|
|
if ! diff "$hook" "$defaulthook" > /dev/null; then |
|
|
|
if ! diff "$hook" "$defaulthook" > /dev/null; then |
|
|
|
( |
|
|
|
resolvedifference "$hook" "$defaulthook" |
|
|
|
printf "\e[31mThe file \e[32m%s\e[31m differs\e[0m\n" "$hook" |
|
|
|
|
|
|
|
smartdiff -ud "$hook" "$defaulthook" |
|
|
|
|
|
|
|
) | less -RF |
|
|
|
|
|
|
|
printf "\e[33mDo you want to remove the custom hook and fall back to the default? [y/N], or perhaps open an editor [e]?\e[0m" |
|
|
|
|
|
|
|
read -r reply < /dev/tty |
|
|
|
|
|
|
|
if [ "y" = "$reply" ]; then |
|
|
|
|
|
|
|
rm "$hook" |
|
|
|
|
|
|
|
elif [ "e" = "$reply" ]; then |
|
|
|
|
|
|
|
$EDITOR "$hook" "$defaulthook" |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
else |
|
|
|
else |
|
|
|
printf "\e[33mHook %s is identical to the default, so you don't need a custom hook, remove it? [Y/n]\e[0m" "$hook" |
|
|
|
printf "\e[33mHook %s is identical to the default, so you don't need a custom hook, remove it? [Y/n]\e[0m" "$hook" |
|
|
|
if [ "n" != "$reply" ]; then |
|
|
|
if [ "n" != "$reply" ]; then |
|
|
|