diff --git a/common/night-theme-switcher.in b/common/night-theme-switcher.in index 6b73c7c..8cb20b5 100755 --- a/common/night-theme-switcher.in +++ b/common/night-theme-switcher.in @@ -128,6 +128,22 @@ check_config() { fi } +_check_for_toolkit_settings_files() { + ## GTK3 + gtk3_settings_file="$XDG_CONFIG_HOME/gtk-3.0/settings.ini" + gtk4_settings_file="$XDG_CONFIG_HOME/gtk-4.0/settings.ini" + qt6ct_settings_file="$XDG_CONFIG_HOME/qt6ct/qt6ct.conf" + + if [[ ! -w "$gtk3_settings_file" ]]; then + touch "$gtk3_settings_file" + fi + if [[ ! -w "$gtk4_settings_file" ]]; then + touch "$gtk4_settings_file" + fi + if [[ ! -w "$qt6ct_settings_file" ]]; then + touch "$qt6ct_settings_file" + fi +} _set_theme() { ## gtk-theme @@ -186,7 +202,7 @@ switch-dark-light() { if [[ ! $gtk_color_scheme == ''\''prefer-dark'\''' ]]; then gtk_color_scheme=prefer-dark - gtk_prefer_dark_theme=true + gtk_prefer_dark_theme=1 gtk_theme=$gtk_theme_dark icon_theme=$icon_theme_dark qt_custom_palette=true @@ -194,7 +210,7 @@ switch-dark-light() { _set_theme else gtk_color_scheme=default - gtk_prefer_dark_theme=false + gtk_prefer_dark_theme=0 gtk_theme=$gtk_theme_light icon_theme=$icon_theme_light qt_custom_palette=true @@ -210,7 +226,7 @@ restore-theme-on-login() { if [[ ! $gtk_color_scheme == ''\''prefer-dark'\''' ]]; then gtk_color_scheme=default - gtk_prefer_dark_theme=false + gtk_prefer_dark_theme=0 gtk_theme=$gtk_theme_light icon_theme=$icon_theme_light qt_custom_palette=true @@ -218,7 +234,7 @@ restore-theme-on-login() { _set_theme else gtk_color_scheme=prefer-dark - gtk_prefer_dark_theme=true + gtk_prefer_dark_theme=1 gtk_theme=$gtk_theme_dark icon_theme=$icon_theme_dark qt_custom_palette=true @@ -269,6 +285,9 @@ case "$1" in r) check_config && restore-theme-on-login ;; + c) + check_config && _check_for_toolkit_settings_files && preview + ;; p) check_config && preview ;; @@ -279,6 +298,7 @@ case "$1" in echo echo -e "${bold} s) swith between dark and light theme${all_off}" echo -e "${bold} r) restore theme (usefull only once after login)${all_off}" + echo -e "${bold} c) create sane default GTK/qt6ct settings files${all_off}" echo -e "${bold} p) Preview settings${all_off}" ;; esac