Compare commits
No commits in common. "main" and "0.0.02" have entirely different histories.
5 changed files with 60 additions and 83 deletions
2
Makefile
2
Makefile
|
|
@ -1,4 +1,4 @@
|
||||||
VERSION = 0.0.05
|
VERSION = 0.0.02
|
||||||
PN = night-theme-switcher
|
PN = night-theme-switcher
|
||||||
|
|
||||||
PREFIX ?= /usr
|
PREFIX ?= /usr
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
Wrapper script to switch between dark and light themes under Arch Linux.
|
Wrapper script to switch between dark and light themes under Arch Linux.
|
||||||
|
|
||||||
## Why use it?
|
## Why use it?
|
||||||
If using a WM like hyprland or sway there is no easy way to change between dark and light themes.
|
If using a barebone WM like hyprland or sway there is no easy way to change between dark and light themes.
|
||||||
|
|
||||||
For example, let's say we have a bunch of application that use KDE/QML/QT and GTK3/4 toolkit. We can now define which themes and icons are used as dark/light themes regardless of the toolkit which these apps are based on.
|
For example, let's say we have a bunch of application that use KDE/QML/QT and GTK3/4 toolkit. We can now define which themes and icons are used as dark/light themes regardless of the toolkit which these apps are based on.
|
||||||
|
|
||||||
|
|
@ -15,7 +15,7 @@ AUR Package: https://BIGFATPLACEHOLDER
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
- `glib2` provides the neccesary `gsettings`.
|
- `glib2` provides the neccesary `gsettings`.
|
||||||
- `qt6ct-kde` a patched version of qt6ct with KDE color schemes support. available in the [`AUR`](https://aur.archlinux.org/packages?O=0&K=qt6ct-kde) ).
|
- [`qt6ct-kde`](https://aur.archlinux.org/packages?O=0&K=qt6ct-kde) (a patched version of qt6ct with KDE color schemes support).
|
||||||
- Any GTK3 theme with dark/light support.
|
- Any GTK3 theme with dark/light support.
|
||||||
- Any KDE color scheme whith dark/light support.
|
- Any KDE color scheme whith dark/light support.
|
||||||
|
|
||||||
|
|
@ -45,6 +45,7 @@ Preview the configured settings:
|
||||||
$ nts p
|
$ nts p
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Tips
|
## Tips
|
||||||
* Since `nts` requires already installed themes, consider having a look into those directories:
|
* Since `nts` requires already installed themes, consider having a look into those directories:
|
||||||
- `/usr/share/color-schemes` for KDE color schemes.
|
- `/usr/share/color-schemes` for KDE color schemes.
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
## NOTE A patched version of qt6ct is required.
|
## NOTE A patched version of qt6ct is required.
|
||||||
## NOTE The benefits are:
|
## NOTE The benefits are
|
||||||
## NOTE KDE color schemes support,KDE QML applications theming support and
|
## NOTE KDE color schemes support,KDE QML applications theming support and
|
||||||
## NOTE KDE's icon engine support
|
## NOTE KDE's icon engine support
|
||||||
## NOTE See https://aur.archlinux.org/pkgbase/qt6ct-kde/
|
## NOTE See https://aur.archlinux.org/pkgbase/qt6ct-kde/
|
||||||
|
|
@ -51,28 +51,6 @@ readonly all_off bold blue green red yellow
|
||||||
### End insert of Arch script
|
### End insert of Arch script
|
||||||
|
|
||||||
# dependency checks probably not needed but they do not hurt
|
# 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
|
if ! command -v qt6ct >/dev/null 2>&1; then
|
||||||
notify-send \
|
notify-send \
|
||||||
'Missing dependency' \
|
'Missing dependency' \
|
||||||
|
|
@ -106,7 +84,7 @@ check_config() {
|
||||||
if [[ ! -f "$user_config_file" ]]; then
|
if [[ ! -f "$user_config_file" ]]; then
|
||||||
echo -e "${bold}------------------------------------------------------------${all_off}"
|
echo -e "${bold}------------------------------------------------------------${all_off}"
|
||||||
echo -e "${bold} No config file found so creating a fresh one in:${all_off}"
|
echo -e "${bold} No config file found so creating a fresh one in:${all_off}"
|
||||||
echo -e "${bold}${blue} $XDG_CONFIG_HOME/$pkgname/$pkgname.conf${all_off}"
|
echo -e "${bold}${blue} $XDG_CONFIG_HOME/$pkgname.conf${all_off}"
|
||||||
echo
|
echo
|
||||||
echo -e "${bold} Edit this file before invoking $pkgname again.${all_off}"
|
echo -e "${bold} Edit this file before invoking $pkgname again.${all_off}"
|
||||||
echo -e "${bold}------------------------------------------------------------${all_off}"
|
echo -e "${bold}------------------------------------------------------------${all_off}"
|
||||||
|
|
@ -150,37 +128,39 @@ check_config() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
_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
|
|
||||||
if [[ ! -w "$gtk4_settings_file" ]]; then
|
|
||||||
touch "$gtk4_settings_file"
|
|
||||||
fi
|
|
||||||
if [[ ! -w "$qt6ct_settings_file" ]]; then
|
|
||||||
touch "$qt6ct_settings_file"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
_set_theme() {
|
_set_theme() {
|
||||||
## GTK
|
## gtk-theme
|
||||||
gsettings set org.gnome.desktop.interface color-scheme "$gtk_color_scheme"
|
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 gtk-theme "$gtk_theme"
|
||||||
gsettings set org.gnome.desktop.interface icon-theme "$icon_theme"
|
gsettings set org.gnome.desktop.interface icon-theme "$icon_theme"
|
||||||
|
|
||||||
## QT
|
## GTK2
|
||||||
if [[ -x /usr/lib/plasma-changeicons ]]; then
|
if [[ -w "$HOME/.gtkrc-2.0" ]]; then
|
||||||
/usr/lib/plasma-changeicons "$icon_theme" >/dev/null 2>&1
|
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
|
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
|
||||||
if [[ -w "$HOME/.config/qt5ct/qt5ct.conf" ]]; then
|
if [[ -w "$HOME/.config/qt5ct/qt5ct.conf" ]]; then
|
||||||
sed -i "s/icon_theme=.*/icon_theme=$icon_theme/g" \
|
sed -i "s/icon_theme=.*/icon_theme=$icon_theme/g" \
|
||||||
"$HOME/.config/qt5ct/qt5ct.conf"
|
"$HOME/.config/qt5ct/qt5ct.conf"
|
||||||
|
|
@ -195,6 +175,10 @@ _set_theme() {
|
||||||
sed -i "s,color_scheme_path=.*,color_scheme_path=$qt_color_scheme_path,g" \
|
sed -i "s,color_scheme_path=.*,color_scheme_path=$qt_color_scheme_path,g" \
|
||||||
"$HOME/.config/qt6ct/qt6ct.conf"
|
"$HOME/.config/qt6ct/qt6ct.conf"
|
||||||
fi
|
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() {
|
switch-dark-light() {
|
||||||
|
|
@ -202,19 +186,19 @@ switch-dark-light() {
|
||||||
|
|
||||||
if [[ ! $gtk_color_scheme == ''\''prefer-dark'\''' ]]; then
|
if [[ ! $gtk_color_scheme == ''\''prefer-dark'\''' ]]; then
|
||||||
gtk_color_scheme=prefer-dark
|
gtk_color_scheme=prefer-dark
|
||||||
gtk_prefer_dark_theme=1
|
gtk_prefer_dark_theme=true
|
||||||
gtk_theme=$gtk_theme_dark
|
gtk_theme=adw-gtk3-dark
|
||||||
icon_theme=$icon_theme_dark
|
icon_theme=Papirus-Dark
|
||||||
qt_custom_palette=true
|
qt_custom_palette=true
|
||||||
qt_color_scheme_path=$kcolorscheme_dark
|
qt_color_scheme_path=/usr/share/color-schemes/BreezeDark.colors
|
||||||
_set_theme
|
_set_theme
|
||||||
else
|
else
|
||||||
gtk_color_scheme=prefer-light
|
gtk_color_scheme=default
|
||||||
gtk_prefer_dark_theme=0
|
gtk_prefer_dark_theme=false
|
||||||
gtk_theme=$gtk_theme_light
|
gtk_theme=adw-gtk3
|
||||||
icon_theme=$icon_theme_light
|
icon_theme=Papirus
|
||||||
qt_custom_palette=true
|
qt_custom_palette=true
|
||||||
qt_color_scheme_path=$kcolorscheme_light
|
qt_color_scheme_path=/usr/share/color-schemes/BreezeLight.colors
|
||||||
_set_theme
|
_set_theme
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
@ -225,20 +209,20 @@ restore-theme-on-login() {
|
||||||
gtk_color_scheme=$(gsettings get org.gnome.desktop.interface color-scheme)
|
gtk_color_scheme=$(gsettings get org.gnome.desktop.interface color-scheme)
|
||||||
|
|
||||||
if [[ ! $gtk_color_scheme == ''\''prefer-dark'\''' ]]; then
|
if [[ ! $gtk_color_scheme == ''\''prefer-dark'\''' ]]; then
|
||||||
gtk_color_scheme=prefer-light
|
gtk_color_scheme=default
|
||||||
gtk_prefer_dark_theme=0
|
gtk_prefer_dark_theme=false
|
||||||
gtk_theme=$gtk_theme_light
|
gtk_theme=adw-gtk3
|
||||||
icon_theme=$icon_theme_light
|
icon_theme=Papirus
|
||||||
qt_custom_palette=true
|
qt_custom_palette=true
|
||||||
qt_color_scheme_path=$kcolorscheme_light
|
qt_color_scheme_path=/usr/share/color-schemes/BreezeLight.colors
|
||||||
_set_theme
|
_set_theme
|
||||||
else
|
else
|
||||||
gtk_color_scheme=prefer-dark
|
gtk_color_scheme=prefer-dark
|
||||||
gtk_prefer_dark_theme=1
|
gtk_prefer_dark_theme=true
|
||||||
gtk_theme=$gtk_theme_dark
|
gtk_theme=adw-gtk3-dark
|
||||||
icon_theme=$icon_theme_dark
|
icon_theme=Papirus-Dark
|
||||||
qt_custom_palette=true
|
qt_custom_palette=true
|
||||||
qt_color_scheme_path=$kcolorscheme_dark
|
qt_color_scheme_path=/usr/share/color-schemes/BreezeDark.colors
|
||||||
_set_theme
|
_set_theme
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
@ -285,9 +269,6 @@ case "$1" in
|
||||||
r)
|
r)
|
||||||
check_config && restore-theme-on-login
|
check_config && restore-theme-on-login
|
||||||
;;
|
;;
|
||||||
c)
|
|
||||||
check_config && _reset_settings && preview
|
|
||||||
;;
|
|
||||||
p)
|
p)
|
||||||
check_config && preview
|
check_config && preview
|
||||||
;;
|
;;
|
||||||
|
|
@ -298,7 +279,6 @@ case "$1" in
|
||||||
echo
|
echo
|
||||||
echo -e "${bold} s) swith between dark and light theme${all_off}"
|
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} 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}"
|
echo -e "${bold} p) Preview settings${all_off}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,13 @@ kcolorscheme_light="/usr/share/color-schemes/BreezeLight.colors"
|
||||||
kcolorscheme_dark="/usr/share/color-schemes/BreezeDark.colors"
|
kcolorscheme_dark="/usr/share/color-schemes/BreezeDark.colors"
|
||||||
|
|
||||||
# Name of the light icon theme
|
# Name of the light icon theme
|
||||||
icon_theme_light=breeze
|
icon_theme_light=Papirus
|
||||||
|
|
||||||
# Name of the dark icon theme
|
# Name of the dark icon theme
|
||||||
icon_theme_dark=breeze-dark
|
icon_theme_dark=Papirus-Dark
|
||||||
|
|
||||||
# Name of the light gtk theme
|
# Name of the light gtk theme
|
||||||
gtk_theme_light=Breeze
|
gtk_theme_light=adw-gtk3
|
||||||
|
|
||||||
# Name of the dark gtk theme
|
# Name of the dark gtk theme
|
||||||
gtk_theme_dark=Breeze-Dark
|
gtk_theme_dark=adw-gtk3-dark
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
.\" Text automatically generated by txt2man
|
.\" Text automatically generated by txt2man
|
||||||
.TH night-theme-switcher 1 "08 December 2025" "" ""
|
.TH night-theme-switcher 1 "05 December 2025" "" ""
|
||||||
.SH NAME
|
.SH NAME
|
||||||
\fBnight-theme-switcher \fP- Wrapper script to switch between dark and light themes.
|
\fBnight-theme-switcher \fP- Wrapper script to switch between dark and light themes.
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.nf
|
.nf
|
||||||
.fam C
|
.fam C
|
||||||
\fBnts\fP [\fIcprs\fP]
|
\fBnts\fP [\fIrsp\fP]
|
||||||
.fam T
|
.fam T
|
||||||
.fi
|
.fi
|
||||||
.fam T
|
.fam T
|
||||||
|
|
@ -16,10 +16,6 @@ while using a barebone WM like hyprland or sway.
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
.B
|
.B
|
||||||
c
|
|
||||||
create sane default GTK/qt6ct settings files
|
|
||||||
.TP
|
|
||||||
.B
|
|
||||||
p
|
p
|
||||||
Preview settings.
|
Preview settings.
|
||||||
.TP
|
.TP
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue