From 8d7913280634e86eb4a66a4fe2e14251ebf5d202 Mon Sep 17 00:00:00 2001 From: bbedward Date: Fri, 22 Aug 2025 08:43:31 -0400 Subject: [PATCH] missing scripts --- scripts/gtk.sh | 66 +++++++++++++++++++++++++++++ scripts/matugen.sh | 103 +++++++++++++++++++++++++++++++++++++++++++++ scripts/qt.sh | 73 ++++++++++++++++++++++++++++++++ 3 files changed, 242 insertions(+) create mode 100755 scripts/gtk.sh create mode 100755 scripts/matugen.sh create mode 100755 scripts/qt.sh diff --git a/scripts/gtk.sh b/scripts/gtk.sh new file mode 100755 index 00000000..5af7d91d --- /dev/null +++ b/scripts/gtk.sh @@ -0,0 +1,66 @@ +#!/usr/bin/env bash + +CONFIG_DIR="$1" +IS_LIGHT="$2" +SHELL_DIR="$3" + +if [ -z "$CONFIG_DIR" ] || [ -z "$IS_LIGHT" ] || [ -z "$SHELL_DIR" ]; then + echo "Usage: $0 " >&2 + exit 1 +fi + +apply_gtk3_colors() { + local config_dir="$1" + local is_light="$2" + local shell_dir="$3" + + local gtk3_dir="$config_dir/gtk-3.0" + local dank_colors="$gtk3_dir/dank-colors.css" + local gtk_css="$gtk3_dir/gtk.css" + + if [ ! -f "$dank_colors" ]; then + echo "Error: dank-colors.css not found at $dank_colors" >&2 + echo "Run matugen first to generate theme files" >&2 + exit 1 + fi + + if [ -L "$gtk_css" ]; then + rm "$gtk_css" + elif [ -f "$gtk_css" ]; then + mv "$gtk_css" "$gtk_css.backup.$(date +%s)" + echo "Backed up existing gtk.css" + fi + + ln -s "dank-colors.css" "$gtk_css" + echo "Created symlink: $gtk_css -> dank-colors.css" +} + +apply_gtk4_colors() { + local config_dir="$1" + + local gtk4_dir="$config_dir/gtk-4.0" + local dank_colors="$gtk4_dir/dank-colors.css" + local gtk_css="$gtk4_dir/gtk.css" + local gtk4_import="@import url(\"dank-colors.css\");" + + if [ ! -f "$dank_colors" ]; then + echo "Error: GTK4 dank-colors.css not found at $dank_colors" >&2 + echo "Run matugen first to generate theme files" >&2 + exit 1 + fi + + if [ -f "$gtk_css" ]; then + sed -i '/^@import url.*dank-colors\.css.*);$/d' "$gtk_css" + sed -i "1i\\$gtk4_import" "$gtk_css" + else + echo "$gtk4_import" > "$gtk_css" + fi + echo "Updated GTK4 CSS import" +} + +mkdir -p "$CONFIG_DIR/gtk-3.0" "$CONFIG_DIR/gtk-4.0" + +apply_gtk3_colors "$CONFIG_DIR" "$IS_LIGHT" "$SHELL_DIR" +apply_gtk4_colors "$CONFIG_DIR" + +echo "GTK colors applied successfully" \ No newline at end of file diff --git a/scripts/matugen.sh b/scripts/matugen.sh new file mode 100755 index 00000000..653f7f85 --- /dev/null +++ b/scripts/matugen.sh @@ -0,0 +1,103 @@ +#!/usr/bin/env bash + +INPUT_SOURCE="$1" +SHELL_DIR="$2" +CONFIG_DIR="$3" +MODE="$4" +IS_LIGHT="$5" +ICON_THEME="$6" + +if [ -z "$SHELL_DIR" ] || [ -z "$CONFIG_DIR" ]; then + echo "Usage: $0 [is_light] [icon_theme]" >&2 + echo " input_source: wallpaper path for 'generate' mode, hex color for 'generate-color' mode" >&2 + exit 1 +fi +MODE=${MODE:-"generate"} +IS_LIGHT=${IS_LIGHT:-"false"} +ICON_THEME=${ICON_THEME:-"System Default"} + +update_theme_settings() { + local color_scheme="$1" + local icon_theme="$2" + + echo "Updating theme settings..." + + if command -v dconf >/dev/null 2>&1; then + dconf write /org/gnome/desktop/interface/color-scheme "\"$color_scheme\"" + echo "Set color-scheme to: $color_scheme" + + if [ "$icon_theme" != "System Default" ] && [ -n "$icon_theme" ]; then + dconf write /org/gnome/desktop/interface/icon-theme "\"$icon_theme\"" + echo "Set icon-theme to: $icon_theme" + fi + elif command -v gsettings >/dev/null 2>&1; then + gsettings set org.gnome.desktop.interface color-scheme "$color_scheme" + echo "Set color-scheme to: $color_scheme" + + if [ "$icon_theme" != "System Default" ] && [ -n "$icon_theme" ]; then + gsettings set org.gnome.desktop.interface icon-theme "$icon_theme" + echo "Set icon-theme to: $icon_theme" + fi + else + echo "Warning: Neither dconf nor gsettings available" + fi +} + +if [ "$MODE" = "generate" ]; then + if [ ! -f "$INPUT_SOURCE" ]; then + echo "Wallpaper file not found: $INPUT_SOURCE" >&2 + exit 1 + fi +elif [ "$MODE" = "generate-color" ]; then + if ! echo "$INPUT_SOURCE" | grep -qE '^#[0-9A-Fa-f]{6}$'; then + echo "Invalid hex color format: $INPUT_SOURCE (expected format: #RRGGBB)" >&2 + exit 1 + fi +fi + +if [ ! -d "$SHELL_DIR" ]; then + echo "Shell directory not found: $SHELL_DIR" >&2 + exit 1 +fi + +mkdir -p "$CONFIG_DIR/gtk-3.0" "$CONFIG_DIR/gtk-4.0" "$CONFIG_DIR/qt5ct/colors" "$CONFIG_DIR/qt6ct/colors" "$(dirname "$CONFIG_DIR")/.local/share/color-schemes" + +cd "$SHELL_DIR" || exit 1 + +if [ ! -f "matugen-config.toml" ]; then + echo "Config file not found: $SHELL_DIR/matugen-config.toml" >&2 + exit 1 +fi + +if [ "$MODE" = "generate" ]; then + echo "Generating matugen themes from wallpaper: $INPUT_SOURCE" + echo "Using config: $SHELL_DIR/matugen-config.toml" + + if ! matugen -v -c matugen-config.toml image "$INPUT_SOURCE"; then + echo "Failed to generate themes with matugen" >&2 + exit 1 + fi +elif [ "$MODE" = "generate-color" ]; then + echo "Generating matugen themes from color: $INPUT_SOURCE" + echo "Using config: $SHELL_DIR/matugen-config.toml" + + if ! matugen -v -c matugen-config.toml color hex "$INPUT_SOURCE"; then + echo "Failed to generate themes with matugen" >&2 + exit 1 + fi +fi + +echo "Updating system theme preferences..." + +color_scheme="" +if [ "$IS_LIGHT" = "true" ]; then + color_scheme="prefer-light" +else + color_scheme="prefer-dark" +fi + +update_theme_settings "$color_scheme" "$ICON_THEME" + +echo "Matugen theme generation completed successfully" +echo "dank-colors.css files generated in $CONFIG_DIR/gtk-3.0/ and $CONFIG_DIR/gtk-4.0/" +echo "Qt color schemes generated in $CONFIG_DIR/qt5ct/colors/ and $CONFIG_DIR/qt6ct/colors/" \ No newline at end of file diff --git a/scripts/qt.sh b/scripts/qt.sh new file mode 100755 index 00000000..032913b3 --- /dev/null +++ b/scripts/qt.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash + +CONFIG_DIR="$1" + +if [ -z "$CONFIG_DIR" ]; then + echo "Usage: $0 " >&2 + exit 1 +fi + +apply_qt_colors() { + local config_dir="$1" + local 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 + sed -i 's/^custom_palette=.*/custom_palette=true/' "$config_file" + 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" + fi + else + 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 + exit 1 + fi +} + +apply_qt_colors "$CONFIG_DIR" + +echo "Qt colors applied successfully" \ No newline at end of file