script: refactor change-colortheme

This commit is contained in:
2025-10-18 02:50:22 +02:00
parent f7fe2b00b5
commit 6f8b7431f9
49 changed files with 360 additions and 1668 deletions

View File

@@ -0,0 +1,32 @@
# snippet to parse args in apply-color scripts
[ -z "$1" ] && exit 1
palette="$1"
[ -z "$2" ] && exit 1
colorName="$2"
[ -z "$3" ] && exit 1
colorHex="$3"
function log_error {
printf "\033[0;31mError:\033[0m $1\n" >&2
}
function log_info {
printf "\033[0;32mInfo:\033[0m $1\n" >&2
}
# remove leading '#' if present
if [[ $colorHex == \#* ]]; then
colorHex="${colorHex#\#}"
fi
# check if hex
if ! [[ $colorHex =~ ^[0-9A-Fa-f]{6}$ ]]; then
log_error "Invalid color hex: $colorHex"
exit 1
fi
function log_success {
log_info "Applied primary color ${colorName} (${colorHex}) to \033[1;34m$1\033[0m"
}