#!/bin/bash # Set theme environment variable for current session and future sessions export THEME="light" echo "export THEME=light" > "$HOME/.theme_env" # Update GTK theme using gsettings (more reliable) if command -v gsettings >/dev/null 2>&1; then gsettings set org.gnome.desktop.interface gtk-theme "Rosepine-Light" gsettings set org.gnome.desktop.interface color-scheme "prefer-light" gsettings set org.gnome.desktop.interface icon-theme "Papirus-Light" fi # Update GTK configuration files directly mkdir -p "$HOME/.config/gtk-3.0" "$HOME/.config/gtk-4.0" # GTK 3 settings cat > "$HOME/.config/gtk-3.0/settings.ini" << EOF [Settings] gtk-application-prefer-dark-theme=false gtk-theme-name=Rosepine-Light gtk-icon-theme-name=Papirus-Light EOF # GTK 4 settings cat > "$HOME/.config/gtk-4.0/settings.ini" << EOF [Settings] gtk-application-prefer-dark-theme=false gtk-theme-name=Rosepine-Light gtk-icon-theme-name=Papirus-Light EOF # GTK 2 settings cat > "$HOME/.gtkrc-2.0" << EOF gtk-theme-name="Rosepine-Light" gtk-icon-theme-name="Papirus-Light" EOF # Update Qt6 theme using qt6ct if command -v qt6ct >/dev/null 2>&1; then export QT_QPA_PLATFORMTHEME=qt6ct mkdir -p "$HOME/.config/qt6ct/colors" if [ -f "$HOME/.config/qt6ct/qt6ct.conf" ]; then sed -i 's/^color_scheme_path=.*/color_scheme_path=\/home\/mike\/.config\/qt6ct\/colors\/rose-pine-dawn.conf/' "$HOME/.config/qt6ct/qt6ct.conf" sed -i 's/^color_scheme=.*/color_scheme=rose-pine-dawn/' "$HOME/.config/qt6ct/qt6ct.conf" else # Create basic qt6ct config if it doesn't exist cat > "$HOME/.config/qt6ct/qt6ct.conf" << EOF [Appearance] color_scheme_path=/home/mike/.config/qt6ct/colors/rose-pine-dawn.conf color_scheme=rose-pine-dawn custom_palette=true standard_dialogs=default style=Fusion [Fonts] fixed=@Variant(\0\0\0@\0\0\0\x12\0M\0o\0n\0o\0s\0p\0\x61\0\x63\0\x65@\"\0\0\0\0\0\0\xff\xff\xff\xff\x5\x1\0\x32\x10) general=@Variant(\0\0\0@\0\0\0\x12\0U\0\x62\0u\0n\0t\0u@\"\0\0\0\0\0\0\xff\xff\xff\xff\x5\x1\0\x32\x10) [Interface] activate_item_on_single_click=1 buttonbox_layout=0 cursor_flash_time=1000 dialog_buttons_have_icons=1 double_click_interval=400 gui_effects=@Invalid() keyboard_scheme=2 menus_have_icons=true show_shortcuts_in_context_menus=true stylesheets=@Invalid() toolbutton_style=4 underline_shortcut=1 wheel_scroll_lines=3 [SettingsWindow] geometry=@ByteArray() EOF fi fi # Update Qt5 theme using qt5ct if command -v qt5ct >/dev/null 2>&1; then export QT_QPA_PLATFORMTHEME=qt5ct mkdir -p "$HOME/.config/qt5ct/colors" if [ -f "$HOME/.config/qt5ct/qt5ct.conf" ]; then sed -i 's/^color_scheme_path=.*/color_scheme_path=\/home\/mike\/.config\/qt5ct\/colors\/rose-pine-dawn.conf/' "$HOME/.config/qt5ct/qt5ct.conf" sed -i 's/^color_scheme=.*/color_scheme=rose-pine-dawn/' "$HOME/.config/qt5ct/qt5ct.conf" else # Create basic qt5ct config if it doesn't exist cat > "$HOME/.config/qt5ct/qt5ct.conf" << EOF [Appearance] color_scheme_path=/home/mike/.config/qt5ct/colors/rose-pine-dawn.conf color_scheme=rose-pine-dawn custom_palette=true standard_dialogs=default style=Fusion [Fonts] fixed=@Variant(\0\0\0@\0\0\0\x12\0M\0o\0n\0o\0s\0p\0\x61\0\x63\0\x65@\"\0\0\0\0\0\0\xff\xff\xff\xff\x5\x1\0\x32\x10) general=@Variant(\0\0\0@\0\0\0\x12\0U\0\x62\0u\0n\0t\0u@\"\0\0\0\0\0\0\xff\xff\xff\xff\x5\x1\0\x32\x10) [Interface] activate_item_on_single_click=1 buttonbox_layout=0 cursor_flash_time=1000 dialog_buttons_have_icons=1 double_click_interval=400 gui_effects=@Invalid() keyboard_scheme=2 menus_have_icons=true show_shortcuts_in_context_menus=true stylesheets=@Invalid() toolbutton_style=4 underline_shortcut=1 wheel_scroll_lines=3 [SettingsWindow] geometry=@ByteArray() EOF fi fi # Update Rofi theme mkdir -p "$HOME/.config/rofi" if [ -f "$HOME/.config/rofi/config.rasi" ]; then # Update existing config.rasi if grep -q "@theme" "$HOME/.config/rofi/config.rasi"; then sed -i 's/@theme ".*"/@theme "rose-pine-dawn"/' "$HOME/.config/rofi/config.rasi" else echo '@theme "rose-pine-dawn"' >> "$HOME/.config/rofi/config.rasi" fi else # Create new config.rasi with Rose Pine Dawn (light) theme cat > "$HOME/.config/rofi/config.rasi" << EOF configuration { modi: "drun,run,window"; show-icons: true; icon-theme: "Papirus-Light"; display-drun: ""; display-run: ""; display-window: ""; drun-display-format: "{name}"; disable-history: false; hide-scrollbar: true; sidebar-mode: false; } @theme "rose-pine-dawn" EOF fi # Update Wezterm theme if [ -f "$HOME/.config/wezterm/wezterm.lua" ]; then # Update Rose Pine theme variant to dawn (light) sed -i "s/local theme = wezterm\.plugin\.require('https:\/\/github\.com\/neapsix\/wezterm')\.\(main\|moon\|dawn\)/local theme = wezterm.plugin.require('https:\/\/github.com\/neapsix\/wezterm').dawn/" "$HOME/.config/wezterm/wezterm.lua" # Also handle manual require statements sed -i "s/local theme = require('lua\/rose-pine')\.\(main\|moon\|dawn\)/local theme = require('lua\/rose-pine').dawn/" "$HOME/.config/wezterm/wezterm.lua" # Fallback for older color_scheme format sed -i 's/config.color_scheme = .*/-- config.color_scheme = "rose-pine-dawn" -- Using custom Rose Pine theme/' "$HOME/.config/wezterm/wezterm.lua" elif [ -f "$HOME/.wezterm.lua" ]; then # Update Rose Pine theme variant to dawn (light) sed -i "s/local theme = wezterm\.plugin\.require('https:\/\/github\.com\/neapsix\/wezterm')\.\(main\|moon\|dawn\)/local theme = wezterm.plugin.require('https:\/\/github.com\/neapsix\/wezterm').dawn/" "$HOME/.wezterm.lua" # Also handle manual require statements sed -i "s/local theme = require('lua\/rose-pine')\.\(main\|moon\|dawn\)/local theme = require('lua\/rose-pine').dawn/" "$HOME/.wezterm.lua" # Fallback for older color_scheme format sed -i 's/config.color_scheme = .*/-- config.color_scheme = "rose-pine-dawn" -- Using custom Rose Pine theme/' "$HOME/.wezterm.lua" fi # Set environment variables for current session export THEME="light" export GTK_THEME="" unset GTK_THEME # Unset to use theme from config files # Create theme indicator file for bar.sh to detect echo "light" > "$HOME/.current_theme" # Verify the file was written if [ "$(cat "$HOME/.current_theme")" = "light" ]; then echo "✓ Theme file updated to 'light'" else echo "✗ Failed to update theme file" fi # Check if bar is running if pgrep -f "bar.sh" > /dev/null; then echo "✓ Bar is running - theme should update immediately" else echo "⚠ Bar is not running - start it with: ~/repos/dwm/bar.sh" fi # Try to reload GTK applications via xsettingsd if available if command -v xsettingsd >/dev/null 2>&1; then pkill -HUP xsettingsd >/dev/null 2>&1 || true fi # Restart GTK settings daemon if using GNOME if pgrep -x "gnome-session" >/dev/null; then dbus-send --session --type=method_call --dest=org.gnome.SettingsDaemon.Color /org/gnome/SettingsDaemon/Color org.gnome.SettingsDaemon.Color.ApplySettings >/dev/null 2>&1 || true fi # Update theme state file for bar.sh echo "light" > "$HOME/.current_theme" # Load light theme Xresources and reload dwm colors if [ -f "$HOME/.Xresources.light" ]; then echo "Loading light theme Xresources..." xrdb -merge "$HOME/.Xresources.light" # Send signal to dwm to reload colors (equivalent to Mod+Shift+F5) # First try using xdotool to simulate the key combination if command -v xdotool >/dev/null 2>&1; then xdotool key --clearmodifiers Super_L+shift+F5 2>/dev/null || true fi # Alternative: if you have dwm-msg or similar IPC tool # dwm-msg run_command xrdb 2>/dev/null || true fi # Refresh system tray icons and Qt applications echo "Refreshing system tray and Qt applications..." # Restart common tray applications to refresh their icons for app in nm-applet blueman-applet pasystray; do if pgrep "$app" >/dev/null; then pkill "$app" 2>/dev/null sleep 0.5 nohup "$app" >/dev/null 2>&1 & fi done # Notify Qt applications of theme change if command -v qt5ct >/dev/null 2>&1; then export QT_QPA_PLATFORMTHEME=qt5ct fi if command -v qt6ct >/dev/null 2>&1; then export QT_QPA_PLATFORMTHEME=qt6ct fi # Notify about theme change echo "Switched to Rose Pine Dawn (light) theme" # Update shell configuration to source theme on new terminals if [ -n "$SHELL" ]; then shell_name=$(basename "$SHELL") case "$shell_name" in "bash") if ! grep -q "source.*\.theme_env" "$HOME/.bashrc" 2>/dev/null; then echo "[ -f \"\$HOME/.theme_env\" ] && source \"\$HOME/.theme_env\"" >> "$HOME/.bashrc" fi ;; "fish") mkdir -p "$HOME/.config/fish" if ! grep -q "source.*\.theme_env" "$HOME/.config/fish/config.fish" 2>/dev/null; then echo "[ -f \"\$HOME/.theme_env\" ] && source \"\$HOME/.theme_env\"" >> "$HOME/.config/fish/config.fish" fi ;; "zsh") if ! grep -q "source.*\.theme_env" "$HOME/.zshrc" 2>/dev/null; then echo "[ -f \"\$HOME/.theme_env\" ] && source \"\$HOME/.theme_env\"" >> "$HOME/.zshrc" fi ;; esac fi