Update 'bin/periodic/fix-theming'

This commit is contained in:
Rokosun 2022-09-19 00:40:44 +02:00
parent 73471917ef
commit 06ccad7d89

View File

@ -1,34 +1,35 @@
#!/bin/bash #!/bin/bash
while read -r line; do while read -r line; do
# Check if the system theme has been changed case "$line" in
if [ "$line" = 'set: /Net/ThemeName' ]; then # When the system theme has been changed
# Get the current system theme 'set: /Net/ThemeName')
theme=$(xfconf-query -c xsettings -p /Net/ThemeName) # Get the current system theme
# Find the best match for the xfwm4 theme that corresponds with the current system theme theme=$(xfconf-query -c xsettings -p /Net/ThemeName)
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) # Find the best match for the xfwm4 theme that corresponds with the current system theme
# If a match is not found then use the Default 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)
[ -z "$xfwm4_theme" ] && xfwm4_theme='Default' # If a match is not found then use the Default theme
# Apply the xfwm4 theme [ -z "$xfwm4_theme" ] && xfwm4_theme='Default'
xfconf-query -c xfwm4 -p /general/theme -n -t string -s "${xfwm4_theme#/}" # Apply the xfwm4 theme
# Apply the current theme with gsettings xfconf-query -c xfwm4 -p /general/theme -n -t string -s "${xfwm4_theme#/}"
gsettings set org.gnome.desktop.interface gtk-theme "$theme" # Apply the current theme with gsettings
gsettings set org.gnome.desktop.interface gtk-theme "$theme"
# Check if the icon theme has been changed ;;
elif [ "$line" = 'set: /Net/IconThemeName' ]; then # When the icon theme has been changed
# Get the current icon theme 'set: /Net/IconThemeName')
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=$(xfconf-query -c xsettings -p /Net/IconThemeName)
sed -i "s/^icon_theme=.*$/icon_theme=$icon_theme/" "$HOME"/.config/qt5ct/qt5ct.conf # Apply the same theme in qt5ct and qt6ct configuration
sed -i "s/^icon_theme=.*$/icon_theme=$icon_theme/" "$HOME"/.config/qt6ct/qt6ct.conf sed -i "s/^icon_theme=.*$/icon_theme=$icon_theme/" "$HOME"/.config/qt5ct/qt5ct.conf
sed -i "s/^icon_theme=.*$/icon_theme=$icon_theme/" "$HOME"/.config/qt6ct/qt6ct.conf
# Check if the system font has been changed ;;
elif [ "$line" = 'set: /Gtk/FontName' ]; then # When the system font has been changed
# Get the current system font 'set: /Gtk/FontName')
font=$(xfconf-query -c xsettings -p /Gtk/FontName) # Get the current system font
# Apply the same font for the title of xfce windows font=$(xfconf-query -c xsettings -p /Gtk/FontName)
xfconf-query -c xfwm4 -p /general/title_font -n -t string -s "$font" # Apply the same font for the title of xfce windows
xfconf-query -c xfwm4 -p /general/title_font -n -t string -s "$font"
fi ;;
esac
done < <(xfconf-query -c xsettings -m) done < <(xfconf-query -c xsettings -m)