1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-28 15:32:50 -05:00

Refactor pre-commit hooks to use prek (#976)

* ci: change to prek for pre-commit

* refactor: fix shellcheck warnings for the scripts

* chore: unify whitespace formatting

* nix: add prek to dev shell
This commit is contained in:
Marcus Ramberg
2025-12-11 15:11:12 +01:00
committed by GitHub
parent c8cfe0cb5a
commit 7c88865d67
147 changed files with 805 additions and 860 deletions

View File

@@ -9,17 +9,18 @@ fi
apply_qt_colors() {
local config_dir="$1"
local color_scheme_path="$(dirname "$config_dir")/.local/share/color-schemes/DankMatugen.colors"
local color_scheme_path
color_scheme_path="$(dirname "$config_dir")/.local/share/color-schemes/DankMatugen.colors"
if [ ! -f "$color_scheme_path" ]; then
echo "Error: Qt color scheme not found at $color_scheme_path" >&2
echo "Run matugen first to generate theme files" >&2
exit 1
fi
update_qt_config() {
local config_file="$1"
if [ -f "$config_file" ]; then
if grep -q '^\[Appearance\]' "$config_file"; then
if grep -q '^custom_palette=' "$config_file"; then
@@ -27,40 +28,42 @@ apply_qt_colors() {
else
sed -i '/^\[Appearance\]/a custom_palette=true' "$config_file"
fi
if grep -q '^color_scheme_path=' "$config_file"; then
sed -i "s|^color_scheme_path=.*|color_scheme_path=$color_scheme_path|" "$config_file"
else
sed -i "/^\\[Appearance\\]/a color_scheme_path=$color_scheme_path" "$config_file"
fi
else
echo "" >> "$config_file"
echo "[Appearance]" >> "$config_file"
echo "custom_palette=true" >> "$config_file"
echo "color_scheme_path=$color_scheme_path" >> "$config_file"
{
echo ""
echo "[Appearance]"
echo "custom_palette=true"
echo "color_scheme_path=$color_scheme_path"
} >>"$config_file"
fi
else
printf '[Appearance]\\ncustom_palette=true\\ncolor_scheme_path=%s\\n' "$color_scheme_path" > "$config_file"
printf '[Appearance]\\ncustom_palette=true\\ncolor_scheme_path=%s\\n' "$color_scheme_path" >"$config_file"
fi
}
qt5_applied=false
qt6_applied=false
if command -v qt5ct >/dev/null 2>&1; then
mkdir -p "$config_dir/qt5ct"
update_qt_config "$config_dir/qt5ct/qt5ct.conf"
echo "Applied Qt5ct configuration"
qt5_applied=true
fi
if command -v qt6ct >/dev/null 2>&1; then
mkdir -p "$config_dir/qt6ct"
update_qt_config "$config_dir/qt6ct/qt6ct.conf"
echo "Applied Qt6ct configuration"
qt6_applied=true
fi
if [ "$qt5_applied" = false ] && [ "$qt6_applied" = false ]; then
echo "Warning: Neither qt5ct nor qt6ct found" >&2
echo "Install qt5ct or qt6ct for Qt application theming" >&2
@@ -70,4 +73,4 @@ apply_qt_colors() {
apply_qt_colors "$CONFIG_DIR"
echo "Qt colors applied successfully"
echo "Qt colors applied successfully"