Compare commits

..

No commits in common. "d44db40e3e6ac5338f6c3784e7734dd81e2f6dfa" and "cea6814e2635683184d21c826a6e5043d40c4ea9" have entirely different histories.

View File

@ -1,34 +1,44 @@
#!/bin/bash #!/bin/sh
while read -r line; do sync_theme() {
# Get the current system theme
theme=$(xfconf-query -c xsettings -p /Net/ThemeName)
# Find the best match for the xfwm4 theme that corresponds with the current system theme
xfwm4_theme=$(find /usr/share/themes/ /usr/local/share/themes/ "$HOME"/.themes/ "$HOME"/.local/share/themes/ -mindepth 2 -maxdepth 2 -type d -name xfwm4 -printf '%h\n' 2>/dev/null | grep -o "/${theme}[^/]*$" | sort | head -n1)
# If a match is not found then use the Default theme
[ -z "$xfwm4_theme" ] && xfwm4_theme='Default'
# Apply the xfwm4 theme
xfconf-query -c xfwm4 -p /general/theme -n -t string -s "${xfwm4_theme#/}"
# Apply the current theme with gsettings
gsettings set org.gnome.desktop.interface gtk-theme "$theme"
}
# Check if the system theme has been changed sync_icon_theme() {
if [ "$line" = 'set: /Net/ThemeName' ]; then # Get the current icon theme
# Get the current system theme icon_theme=$(xfconf-query -c xsettings -p /Net/IconThemeName)
theme=$(xfconf-query -c xsettings -p /Net/ThemeName) # Apply the same theme in qt5ct and qt6ct configuration
# Find the best match for the xfwm4 theme that corresponds with the current system theme sed -i "s/^icon_theme=.*$/icon_theme=$icon_theme/" "$HOME"/.config/qt5ct/qt5ct.conf
xfwm4_theme=$(find /usr/share/themes/ /usr/local/share/themes/ "$HOME"/.themes/ "$HOME"/.local/share/themes/ -mindepth 2 -maxdepth 2 -type d -name xfwm4 -printf '%h\n' 2>/dev/null | grep -o "/${theme}[^/]*$" | sort | head -n1) sed -i "s/^icon_theme=.*$/icon_theme=$icon_theme/" "$HOME"/.config/qt6ct/qt6ct.conf
# If a match is not found then use the Default theme }
[ -z "$xfwm4_theme" ] && xfwm4_theme='Default'
# Apply the xfwm4 theme
xfconf-query -c xfwm4 -p /general/theme -n -t string -s "${xfwm4_theme#/}"
# Apply the current theme with gsettings
gsettings set org.gnome.desktop.interface gtk-theme "$theme"
# Check if the icon theme has been changed while :; do
elif [ "$line" = 'set: /Net/IconThemeName' ]; then # Get the current system theme
# Get the current icon theme theme_new=$(xfconf-query -c xsettings -p /Net/ThemeName)
icon_theme=$(xfconf-query -c xsettings -p /Net/IconThemeName) # Get the current icon theme
# Apply the same theme in qt5ct and qt6ct configuration icon_theme_new=$(xfconf-query -c xsettings -p /Net/IconThemeName)
sed -i "s/^icon_theme=.*$/icon_theme=$icon_theme/" "$HOME"/.config/qt5ct/qt5ct.conf # Get the current font name
sed -i "s/^icon_theme=.*$/icon_theme=$icon_theme/" "$HOME"/.config/qt6ct/qt6ct.conf font_new=$(xfconf-query -c xsettings -p /Gtk/FontName)
# Check if the system font has been changed # Run sync_theme if the new system theme doesn't match the previous one
elif [ "$line" = 'set: /Gtk/FontName' ]; then [ "$theme_new" != "$theme_prev" ] && sync_theme
# Get the current system font # Run sync_icon_theme if the new icon theme doesn't match the previous one
font=$(xfconf-query -c xsettings -p /Gtk/FontName) [ "$icon_theme_new" != "$icon_theme_prev" ] && sync_icon_theme
# Apply the same font for the title of xfce windows # If the new font doesn't match the previous one, apply the new font for the title of xfce windows
xfconf-query -c xfwm4 -p /general/title_font -n -t string -s "$font" [ "$font_new" != "$font_prev" ] && xfconf-query -c xfwm4 -p /general/title_font -n -t string -s "$font_new"
fi # The new values become the previous values
theme_prev=$theme_new
icon_theme_prev=$icon_theme_new
font_prev=$font_new
done < <(xfconf-query -c xsettings -m) sleep 3
done