From 2976fbab63272c7e90c3ecae928a4a8dd94dd321 Mon Sep 17 00:00:00 2001 From: grassblock Date: Wed, 1 Jan 2025 11:23:15 +0800 Subject: [PATCH] feat: use kitty auto dark mode added in 0.38.0 --- home/private_dot_config/kitty/kitty.conf | 6 +++-- .../kitty/symlink_dark-theme.auto.conf | 1 + .../kitty/symlink_light-theme.auto.conf | 1 + .../symlink_no-preference-theme.auto.conf | 1 + .../executable_desktop-notification.sh | 5 +++- .../dark-mode.d/executable_global-theme.sh | 26 ++++++++++++++----- .../dark-mode.d/executable_kde-gtk-theme.sh | 5 ++++ .../executable_desktop-notification.sh | 6 ++++- .../light-mode.d/executable_global-theme.sh | 25 +++++++++++++----- .../light-mode.d/executable_kde-gtk-theme.sh | 5 ++++ 10 files changed, 63 insertions(+), 18 deletions(-) create mode 100644 home/private_dot_config/kitty/symlink_dark-theme.auto.conf create mode 100644 home/private_dot_config/kitty/symlink_light-theme.auto.conf create mode 100644 home/private_dot_config/kitty/symlink_no-preference-theme.auto.conf diff --git a/home/private_dot_config/kitty/kitty.conf b/home/private_dot_config/kitty/kitty.conf index 13bc0fe..2c31069 100644 --- a/home/private_dot_config/kitty/kitty.conf +++ b/home/private_dot_config/kitty/kitty.conf @@ -1,11 +1,13 @@ # themes -include ./themes.conf +# outdated: https://sw.kovidgoyal.net/kitty/kittens/themes/#change-color-themes-automatically-when-the-os-switches-between-light-and-dark + +# include ./current-theme.conf # the old way #include ./nord.conf # bg opacity & blur -background_opacity 0.8 +background_opacity 0.7 background_blur 16 # fonts diff --git a/home/private_dot_config/kitty/symlink_dark-theme.auto.conf b/home/private_dot_config/kitty/symlink_dark-theme.auto.conf new file mode 100644 index 0000000..a8ba245 --- /dev/null +++ b/home/private_dot_config/kitty/symlink_dark-theme.auto.conf @@ -0,0 +1 @@ +/home/grassblock/.config/kitty/themes/nord-dark.conf diff --git a/home/private_dot_config/kitty/symlink_light-theme.auto.conf b/home/private_dot_config/kitty/symlink_light-theme.auto.conf new file mode 100644 index 0000000..74d015f --- /dev/null +++ b/home/private_dot_config/kitty/symlink_light-theme.auto.conf @@ -0,0 +1 @@ +/home/grassblock/.config/kitty/themes/nord-light.conf diff --git a/home/private_dot_config/kitty/symlink_no-preference-theme.auto.conf b/home/private_dot_config/kitty/symlink_no-preference-theme.auto.conf new file mode 100644 index 0000000..a8ba245 --- /dev/null +++ b/home/private_dot_config/kitty/symlink_no-preference-theme.auto.conf @@ -0,0 +1 @@ +/home/grassblock/.config/kitty/themes/nord-dark.conf diff --git a/home/private_dot_local/private_share/dark-mode.d/executable_desktop-notification.sh b/home/private_dot_local/private_share/dark-mode.d/executable_desktop-notification.sh index e29e357..cacad6a 100644 --- a/home/private_dot_local/private_share/dark-mode.d/executable_desktop-notification.sh +++ b/home/private_dot_local/private_share/dark-mode.d/executable_desktop-notification.sh @@ -1,6 +1,9 @@ #!/usr/bin/env bash +# add a detection to prevent exec scripts on every login +#if [[ "$(darkman get)" =~ "light" ]] ; then # trigger a small, passive popup dialog to inform the user about darkman's activity # reference https://wiki.archlinux.org/title/Desktop_notifications#Usage_in_programming -notify-send --app-name="darkman" --urgency=low --icon=weather-clear-night "switching to dark mode" \ No newline at end of file +notify-send --app-name="darkman" --urgency=low --icon=weather-clear-night "switching to dark mode" +#fi diff --git a/home/private_dot_local/private_share/dark-mode.d/executable_global-theme.sh b/home/private_dot_local/private_share/dark-mode.d/executable_global-theme.sh index 5a01aa6..f05c492 100644 --- a/home/private_dot_local/private_share/dark-mode.d/executable_global-theme.sh +++ b/home/private_dot_local/private_share/dark-mode.d/executable_global-theme.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash -# Change the global Plasma Theme. On Manjaro you can use "org.manjaro.breath-dark.desktop" +# add a detection to prevent exec scripts on every login +#if [[ "$(darkman get)" =~ "light" ]] ; then +# Change the global Plasma Theme. On Manjaro you can use "org.manjaro.breath-dark.desktop" # or you can create your own global Plasma Theme with the "Plasma Look And Feel Explorer". # Reference: https://userbase.kde.org/Plasma/Create_a_Global_Theme_Package # @@ -10,12 +12,6 @@ # Global Theme lookandfeeltool -platform offscreen --apply "Utterly-Nord" -# Window decoration -# https://askubuntu.com/questions/1183294/switching-plasma-theme-from-the-command-line -kwriteconfig6 --file ~/.config/kwinrc --group org.kde.kdecoration2 --key library org.kde.klassy - -kwriteconfig6 --file ~/.config/kwinrc --group org.kde.kdecoration2 --key theme Klassy - # Icon theme /usr/lib/plasma-changeicons Papirus-Dark @@ -26,9 +22,25 @@ flatpak run --command="gradience-cli" com.github.GradienceTeam.Gradience apply - # https://reddit.com/r/kde/comments/f7wemr/how_change_application_style_without_system/ kwriteconfig6 --file kdeglobals --group KDE --key widgetStyle Lightly +# Window decoration +# https://askubuntu.com/questions/1183294/switching-plasma-theme-from-the-command-line +kwriteconfig6 --file ~/.config/kwinrc --group org.kde.kdecoration2 --key library org.kde.klassy + +kwriteconfig6 --file ~/.config/kwinrc --group org.kde.kdecoration2 --key theme Klassy + # cursorTheme # https://askubuntu.com/questions/1025338/how-can-i-set-the-cursor-theme-on-kde-plasma-5-programmatically kwriteconfig6 --file ~/.config/kcminputrc --group Mouse --key cursorTheme Bibata-Modern-Ice +# make kwin to reload config +# https://invent.kde.org/plasma/kwin/-/blob/master/src/kcms/decoration/kwin-applywindowdecoration.cpp#L95 +# https://develop.kde.org/docs/plasma/kwin/#installation +dbus-send --session --type=signal /Kwin org.kde.KWin.reloadConfig +qdbus org.kde.KWin /KWin org.kde.KWin.reconfigure + + # notify notify-send --app-name="darkman" --urgency=low --icon=weather-clear "theme switch success. to make them fully take effect, please logout and login again." +#else +# echo "The global theme has been already switched, skipping" +#fi diff --git a/home/private_dot_local/private_share/dark-mode.d/executable_kde-gtk-theme.sh b/home/private_dot_local/private_share/dark-mode.d/executable_kde-gtk-theme.sh index 49132ee..a963dc2 100644 --- a/home/private_dot_local/private_share/dark-mode.d/executable_kde-gtk-theme.sh +++ b/home/private_dot_local/private_share/dark-mode.d/executable_kde-gtk-theme.sh @@ -1,7 +1,12 @@ #!/usr/bin/env bash +# add a detection to prevent exec scripts on every login +#if [[ "$(darkman get)" =~ "light" ]] ; then # GTK apps are not affected by the Plasma Global Theme, which only applies to Qt based programs. # GTK themes can be installed here: Global Theme > Application Style > Configure GNOME/GTK Application Style. # Reference: https://wiki.archlinux.org/title/Uniform_look_for_Qt_and_GTK_applications dbus-send --session --dest=org.kde.GtkConfig --type=method_call /GtkConfig org.kde.GtkConfig.setGtkTheme "string:Nordic-bluish-dark" +#else +# echo "The GTK theme has been already switched, skipping" +#fi diff --git a/home/private_dot_local/private_share/light-mode.d/executable_desktop-notification.sh b/home/private_dot_local/private_share/light-mode.d/executable_desktop-notification.sh index 160edde..3ff97b2 100644 --- a/home/private_dot_local/private_share/light-mode.d/executable_desktop-notification.sh +++ b/home/private_dot_local/private_share/light-mode.d/executable_desktop-notification.sh @@ -1,6 +1,10 @@ #!/usr/bin/env bash +# add a detection to prevent exec scripts on every login +#if [[ "$(darkman get)" =~ "dark" ]]; then # trigger a small, passive popup dialog to inform the user about darkman's activity # reference https://wiki.archlinux.org/title/Desktop_notifications#Usage_in_programming -notify-send --app-name="darkman" --urgency=low --icon=weather-clear "switching to light mode" \ No newline at end of file +notify-send --app-name="darkman" --urgency=low --icon=weather-clear "switching to light mode" + +#fi diff --git a/home/private_dot_local/private_share/light-mode.d/executable_global-theme.sh b/home/private_dot_local/private_share/light-mode.d/executable_global-theme.sh index 4f0afd7..6081356 100644 --- a/home/private_dot_local/private_share/light-mode.d/executable_global-theme.sh +++ b/home/private_dot_local/private_share/light-mode.d/executable_global-theme.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash -# Change the global Plasma Theme. On Manjaro you can use "org.manjaro.breath-light.desktop" +# add a detection to prevent exec scripts on every login +#if [[ "$(darkman get)" =~ "dark" ]] ; then +# Change the global Plasma Theme. On Manjaro you can use "org.manjaro.breath-light.desktop" # or you can create your own global Plasma Theme with the "Plasma Look And Feel Explorer". # Reference: https://userbase.kde.org/Plasma/Create_a_Global_Theme_Package # @@ -10,12 +12,6 @@ # Global Theme lookandfeeltool -platform offscreen --apply "Utterly-Nord-Light" -# Window decoration -# https://askubuntu.com/questions/1183294/switching-plasma-theme-from-the-command-line -kwriteconfig6 --file ~/.config/kwinrc --group org.kde.kdecoration2 --key library org.kde.klassy - -kwriteconfig6 --file ~/.config/kwinrc --group org.kde.kdecoration2 --key theme Klassy - # Icon theme /usr/lib/plasma-changeicons Papirus-Light @@ -25,5 +21,20 @@ flatpak run --command="gradience-cli" com.github.GradienceTeam.Gradience apply - # application style kwriteconfig6 --file kdeglobals --group KDE --key widgetStyle Lightly +# Window decoration +# https://askubuntu.com/questions/1183294/switching-plasma-theme-from-the-command-line +kwriteconfig6 --file ~/.config/kwinrc --group org.kde.kdecoration2 --key library org.kde.klassy + +kwriteconfig6 --file ~/.config/kwinrc --group org.kde.kdecoration2 --key theme Klassy + +# make kwin to reload config +# https://invent.kde.org/plasma/kwin/-/blob/master/src/kcms/decoration/kwin-applywindowdecoration.cpp#L95 +# https://develop.kde.org/docs/plasma/kwin/#installation +dbus-send --session --type=signal /Kwin org.kde.KWin.reloadConfig +qdbus org.kde.KWin /KWin org.kde.KWin.reconfigure + # notify notify-send --app-name="darkman" --urgency=low --icon=weather-clear "theme switch success. to make them fully take effect, please logout and login again." +#else +# echo "The global theme has been already switched,skipping" +#fi diff --git a/home/private_dot_local/private_share/light-mode.d/executable_kde-gtk-theme.sh b/home/private_dot_local/private_share/light-mode.d/executable_kde-gtk-theme.sh index 4769819..abfdca1 100644 --- a/home/private_dot_local/private_share/light-mode.d/executable_kde-gtk-theme.sh +++ b/home/private_dot_local/private_share/light-mode.d/executable_kde-gtk-theme.sh @@ -1,7 +1,12 @@ #!/usr/bin/env bash +# add a detection to prevent exec scripts on every login +#if [[ "$(darkman get)" =~ "dark" ]] ; then # GTK apps are not affected by the Plasma Global Theme, which only applies to Qt based programs. # GTK themes can be installed here: Global Theme > Application Style > Configure GNOME/GTK Application Style. # Reference: https://wiki.archlinux.org/title/Uniform_look_for_Qt_and_GTK_applications dbus-send --session --dest=org.kde.GtkConfig --type=method_call /GtkConfig org.kde.GtkConfig.setGtkTheme "string:Graphite-Light-nord" +#else +# echo "The GTK theme has been already switched, skipping" +#fi