From 334fa18594e916097755f4584c763b1c90e291b7 Mon Sep 17 00:00:00 2001 From: Christian Schendel Date: Sun, 7 Dec 2025 16:20:34 +0000 Subject: [PATCH 01/10] [feature] check for GTK3/qt6c settings files (in progress 1) --- common/night-theme-switcher.in | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) 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 From 7d29b4e76676cd5184b6c9ebefe946b2f97ce6b3 Mon Sep 17 00:00:00 2001 From: Christian Schendel Date: Sun, 7 Dec 2025 20:52:42 +0000 Subject: [PATCH 02/10] [feature] check for GTK3/qt6c settings files (in progress 2) --- common/night-theme-switcher.in | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/common/night-theme-switcher.in b/common/night-theme-switcher.in index 8cb20b5..51f800d 100755 --- a/common/night-theme-switcher.in +++ b/common/night-theme-switcher.in @@ -128,12 +128,16 @@ check_config() { fi } -_check_for_toolkit_settings_files() { +_reset_settings() { ## 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" + gsettings reset org.gnome.desktop.interface color-scheme + gsettings reset org.gnome.desktop.interface gtk-theme + gsettings reset org.gnome.desktop.interface icon-theme + if [[ ! -w "$gtk3_settings_file" ]]; then touch "$gtk3_settings_file" fi @@ -286,7 +290,7 @@ case "$1" in check_config && restore-theme-on-login ;; c) - check_config && _check_for_toolkit_settings_files && preview + check_config && _reset_settings && preview ;; p) check_config && preview From c450c079134cee054cd5af10c893bbf94cdfea1e Mon Sep 17 00:00:00 2001 From: Christian Schendel Date: Mon, 8 Dec 2025 10:55:57 +0000 Subject: [PATCH 03/10] [feature] check for check for plasma-workspace (in progress 4) --- common/night-theme-switcher.in | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/common/night-theme-switcher.in b/common/night-theme-switcher.in index 51f800d..a7fdad2 100755 --- a/common/night-theme-switcher.in +++ b/common/night-theme-switcher.in @@ -74,6 +74,17 @@ if ! command -v gsettings >/dev/null 2>&1; then echo -e "${red}==> ERROR:${all_off}${bold} ${mesg}${all_off}" exit 1 fi +if ! command -v /usr/lib/plasma-changeicons >/dev/null 2>&1; then + notify-send \ + 'Missing dependency' \ + 'plasma-changeicons not found.\nPlease install plasma-workspace.' \ + -h string:x-canonical-private-synchronous:sys-notify \ + -u critical \ + -i dialog-error + mesg="plasma-workspace is required to use this script." + echo -e "${red}==> ERROR:${all_off}${bold} ${mesg}${all_off}" + exit 1 +fi check_config() { if [[ ! -f $default_config_file ]]; then @@ -154,6 +165,7 @@ _set_theme() { gsettings set org.gnome.desktop.interface color-scheme "$gtk_color_scheme" gsettings set org.gnome.desktop.interface gtk-theme "$gtk_theme" gsettings set org.gnome.desktop.interface icon-theme "$icon_theme" + /usr/lib/plasma-changeicons "$icon_theme" >/dev/null 2>&1 ## GTK2 if [[ -w "$HOME/.gtkrc-2.0" ]]; then @@ -195,10 +207,6 @@ _set_theme() { sed -i "s,color_scheme_path=.*,color_scheme_path=$qt_color_scheme_path,g" \ "$HOME/.config/qt6ct/qt6ct.conf" fi - ## workaround if plasma-workspace is installed - if [ -x "$(command -v /usr/lib/plasma-changeicon)" ]; then - /usr/lib/plasma-changeicons "$icon_theme" - fi } switch-dark-light() { From 77037021eedb759af5f924bd4c87a83c52361201 Mon Sep 17 00:00:00 2001 From: Christian Schendel Date: Mon, 8 Dec 2025 22:01:55 +0000 Subject: [PATCH 04/10] [feature] remove use of sed in the GTK section (in progress 5) --- common/night-theme-switcher.in | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/common/night-theme-switcher.in b/common/night-theme-switcher.in index a7fdad2..89525a8 100755 --- a/common/night-theme-switcher.in +++ b/common/night-theme-switcher.in @@ -161,38 +161,13 @@ _reset_settings() { } _set_theme() { - ## gtk-theme + ## GTK gsettings set org.gnome.desktop.interface color-scheme "$gtk_color_scheme" gsettings set org.gnome.desktop.interface gtk-theme "$gtk_theme" gsettings set org.gnome.desktop.interface icon-theme "$icon_theme" - /usr/lib/plasma-changeicons "$icon_theme" >/dev/null 2>&1 - ## GTK2 - if [[ -w "$HOME/.gtkrc-2.0" ]]; then - sed -i "s/gtk-theme-name=.*/gtk-theme-name=$gtk_theme/g" \ - "$HOME/.gtkrc-2.0" - sed -i "s/gtk-icon-theme-name=.*/gtk-icon-theme-name=$icon_theme/g" \ - "$HOME/.gtkrc-2.0" - fi - ## GTK3 - if [[ -w "$HOME/.config/gtk-3.0/settings.ini" ]]; then - sed -i "s/gtk-application-prefer-dark-theme=.*/gtk-application-prefer-dark-theme=$gtk_prefer_dark_theme/g" \ - "$HOME/.config/gtk-3.0/settings.ini" - sed -i "s/gtk-theme-name=.*/gtk-theme-name=$gtk_theme/g" \ - "$HOME/.config/gtk-3.0/settings.ini" - sed -i "s/gtk-icon-theme-name=.*/gtk-icon-theme-name=$icon_theme/g" \ - "$HOME/.config/gtk-3.0/settings.ini" - fi - ## GTK4 - if [[ -w "$HOME/.config/gtk-4.0/settings.ini" ]]; then - sed -i "s/gtk-application-prefer-dark-theme=.*/gtk-application-prefer-dark-theme=$gtk_prefer_dark_theme/g" \ - "$HOME/.config/gtk-4.0/settings.ini" - sed -i "s/gtk-icon-theme-name=.*/gtk-icon-theme-name=$icon_theme/g" \ - "$HOME/.config/gtk-4.0/settings.ini" - sed -i "s/gtk-theme-name=.*/gtk-theme-name=$gtk_theme/g" \ - "$HOME/.config/gtk-4.0/settings.ini" - fi ## QT + /usr/lib/plasma-changeicons "$icon_theme" >/dev/null 2>&1 if [[ -w "$HOME/.config/qt5ct/qt5ct.conf" ]]; then sed -i "s/icon_theme=.*/icon_theme=$icon_theme/g" \ "$HOME/.config/qt5ct/qt5ct.conf" From 130a32b64197bc368f5a2064548bada987ab12d5 Mon Sep 17 00:00:00 2001 From: Christian Schendel Date: Mon, 8 Dec 2025 22:14:14 +0000 Subject: [PATCH 05/10] [docs] update manpage --- doc/night-theme-switcher.1 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/night-theme-switcher.1 b/doc/night-theme-switcher.1 index fb851f0..3d08a21 100644 --- a/doc/night-theme-switcher.1 +++ b/doc/night-theme-switcher.1 @@ -1,11 +1,11 @@ .\" Text automatically generated by txt2man -.TH night-theme-switcher 1 "05 December 2025" "" "" +.TH night-theme-switcher 1 "08 December 2025" "" "" .SH NAME \fBnight-theme-switcher \fP- Wrapper script to switch between dark and light themes. .SH SYNOPSIS .nf .fam C -\fBnts\fP [\fIrsp\fP] +\fBnts\fP [\fIcprs\fP] .fam T .fi .fam T @@ -16,6 +16,10 @@ while using a barebone WM like hyprland or sway. .SH OPTIONS .TP .B +c +create sane default GTK/qt6ct settings files +.TP +.B p Preview settings. .TP From bc036b47f598de4bdb6e37ace04f9b19c7ee4003 Mon Sep 17 00:00:00 2001 From: Christian Schendel Date: Mon, 8 Dec 2025 22:16:32 +0000 Subject: [PATCH 06/10] [build] increment version to 0.0.04 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c38d0a6..08fd05d 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION = 0.0.03 +VERSION = 0.0.04 PN = night-theme-switcher PREFIX ?= /usr From 53e31eee65c7f7152aca76b61410e85296d4bc15 Mon Sep 17 00:00:00 2001 From: Christian Schendel Date: Tue, 9 Dec 2025 10:42:46 +0000 Subject: [PATCH 07/10] fix(color-scheme): use prefer-light instead of default default will show some context-menus e.g. waybar-tray in dark --- common/night-theme-switcher.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/night-theme-switcher.in b/common/night-theme-switcher.in index 89525a8..a9b6f53 100755 --- a/common/night-theme-switcher.in +++ b/common/night-theme-switcher.in @@ -196,7 +196,7 @@ switch-dark-light() { qt_color_scheme_path=$kcolorscheme_dark _set_theme else - gtk_color_scheme=default + gtk_color_scheme=prefer-light gtk_prefer_dark_theme=0 gtk_theme=$gtk_theme_light icon_theme=$icon_theme_light @@ -212,7 +212,7 @@ restore-theme-on-login() { gtk_color_scheme=$(gsettings get org.gnome.desktop.interface color-scheme) if [[ ! $gtk_color_scheme == ''\''prefer-dark'\''' ]]; then - gtk_color_scheme=default + gtk_color_scheme=prefer-light gtk_prefer_dark_theme=0 gtk_theme=$gtk_theme_light icon_theme=$icon_theme_light From 216f3866cbb5768b57123602f0ac8f6a9e71bf43 Mon Sep 17 00:00:00 2001 From: Christian Schendel Date: Thu, 11 Dec 2025 19:05:25 +0100 Subject: [PATCH 08/10] bugfix: more QT checking - check for QT_QPA_PLATFORMTHEME=qt6ct - make plasma-changeicons optional --- common/night-theme-switcher.in | 37 +++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/common/night-theme-switcher.in b/common/night-theme-switcher.in index a9b6f53..6c8ab79 100755 --- a/common/night-theme-switcher.in +++ b/common/night-theme-switcher.in @@ -51,6 +51,28 @@ readonly all_off bold blue green red yellow ### End insert of Arch script # dependency checks probably not needed but they do not hurt +if [ ! "$QT_QPA_PLATFORMTHEME" == "qt6ct" ]; then + notify-send \ + 'Wrong environment variable' \ + 'Please set QT_QPA_PLATFORMTHEME=qt6ct.' \ + -h string:x-canonical-private-synchronous:sys-notify \ + -u critical \ + -i dialog-error + mesg="environment variable QT_QPA_PLATFORMTHEME=qt6ct is not set." + echo -e "${red}==> ERROR:${all_off}${bold} ${mesg}${all_off}" + exit 1 +fi +if ! command -v breeze-settings6 >/dev/null 2>&1; then + notify-send \ + 'Missing dependency' \ + 'Please install breeze.' \ + -h string:x-canonical-private-synchronous:sys-notify \ + -u critical \ + -i dialog-error + mesg="breeze is required to use this script." + echo -e "${red}==> ERROR:${all_off}${bold} ${mesg}${all_off}" + exit 1 +fi if ! command -v qt6ct >/dev/null 2>&1; then notify-send \ 'Missing dependency' \ @@ -74,17 +96,6 @@ if ! command -v gsettings >/dev/null 2>&1; then echo -e "${red}==> ERROR:${all_off}${bold} ${mesg}${all_off}" exit 1 fi -if ! command -v /usr/lib/plasma-changeicons >/dev/null 2>&1; then - notify-send \ - 'Missing dependency' \ - 'plasma-changeicons not found.\nPlease install plasma-workspace.' \ - -h string:x-canonical-private-synchronous:sys-notify \ - -u critical \ - -i dialog-error - mesg="plasma-workspace is required to use this script." - echo -e "${red}==> ERROR:${all_off}${bold} ${mesg}${all_off}" - exit 1 -fi check_config() { if [[ ! -f $default_config_file ]]; then @@ -167,7 +178,9 @@ _set_theme() { gsettings set org.gnome.desktop.interface icon-theme "$icon_theme" ## QT - /usr/lib/plasma-changeicons "$icon_theme" >/dev/null 2>&1 + if [[ -x /usr/lib/plasma-changeicons ]]; then + /usr/lib/plasma-changeicons "$icon_theme" >/dev/null 2>&1 + fi if [[ -w "$HOME/.config/qt5ct/qt5ct.conf" ]]; then sed -i "s/icon_theme=.*/icon_theme=$icon_theme/g" \ "$HOME/.config/qt5ct/qt5ct.conf" From 4d66a770896ec08c70e01b2a3e229ad0a054a090 Mon Sep 17 00:00:00 2001 From: Christian Schendel Date: Thu, 11 Dec 2025 19:17:09 +0100 Subject: [PATCH 09/10] bugfix: set Breeze theme as default in config file --- common/nts.skel | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/nts.skel b/common/nts.skel index f98df54..4ad2dae 100644 --- a/common/nts.skel +++ b/common/nts.skel @@ -5,13 +5,13 @@ kcolorscheme_light="/usr/share/color-schemes/BreezeLight.colors" kcolorscheme_dark="/usr/share/color-schemes/BreezeDark.colors" # Name of the light icon theme -icon_theme_light=Papirus +icon_theme_light=breeze # Name of the dark icon theme -icon_theme_dark=Papirus-Dark +icon_theme_dark=breeze-dark # Name of the light gtk theme -gtk_theme_light=adw-gtk3 +gtk_theme_light=Breeze # Name of the dark gtk theme -gtk_theme_dark=adw-gtk3-dark +gtk_theme_dark=Breeze-Dark From 17095c11c8db251049ed9ac6e2848e5ac77c519f Mon Sep 17 00:00:00 2001 From: Christian Schendel Date: Thu, 11 Dec 2025 19:18:32 +0100 Subject: [PATCH 10/10] version 0.0.05 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 08fd05d..43dcb38 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION = 0.0.04 +VERSION = 0.0.05 PN = night-theme-switcher PREFIX ?= /usr