Use the -m option in xfconf-query to monitor for changes #5
|
@ -1,5 +1,8 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
sync_theme() {
|
while read -r line; do
|
||||||
|
|
||||||
|
# Check if the system theme has been changed
|
||||||
|
if [ "$line" = 'set: /Net/ThemeName' ]; then
|
||||||
rokosun marked this conversation as resolved
|
|||||||
# Get the current system theme
|
# Get the current system theme
|
||||||
theme=$(xfconf-query -c xsettings -p /Net/ThemeName)
|
theme=$(xfconf-query -c xsettings -p /Net/ThemeName)
|
||||||
# Find the best match for the xfwm4 theme that corresponds with the current system theme
|
# Find the best match for the xfwm4 theme that corresponds with the current system theme
|
||||||
|
@ -10,35 +13,22 @@ sync_theme() {
|
||||||
xfconf-query -c xfwm4 -p /general/theme -n -t string -s "${xfwm4_theme#/}"
|
xfconf-query -c xfwm4 -p /general/theme -n -t string -s "${xfwm4_theme#/}"
|
||||||
# Apply the current theme with gsettings
|
# Apply the current theme with gsettings
|
||||||
gsettings set org.gnome.desktop.interface gtk-theme "$theme"
|
gsettings set org.gnome.desktop.interface gtk-theme "$theme"
|
||||||
}
|
|
||||||
|
|
||||||
sync_icon_theme() {
|
# Check if the icon theme has been changed
|
||||||
|
elif [ "$line" = 'set: /Net/IconThemeName' ]; then
|
||||||
# Get the current icon theme
|
# Get the current icon theme
|
||||||
icon_theme=$(xfconf-query -c xsettings -p /Net/IconThemeName)
|
icon_theme=$(xfconf-query -c xsettings -p /Net/IconThemeName)
|
||||||
# Apply the same theme in qt5ct and qt6ct configuration
|
# Apply the same theme in qt5ct and qt6ct configuration
|
||||||
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/qt5ct/qt5ct.conf
|
||||||
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/qt6ct/qt6ct.conf
|
||||||
}
|
|
||||||
|
|
||||||
while :; do
|
# Check if the system font has been changed
|
||||||
# Get the current system theme
|
elif [ "$line" = 'set: /Gtk/FontName' ]; then
|
||||||
theme_new=$(xfconf-query -c xsettings -p /Net/ThemeName)
|
# Get the current system font
|
||||||
# Get the current icon theme
|
font=$(xfconf-query -c xsettings -p /Gtk/FontName)
|
||||||
icon_theme_new=$(xfconf-query -c xsettings -p /Net/IconThemeName)
|
# Apply the same font for the title of xfce windows
|
||||||
# Get the current font name
|
xfconf-query -c xfwm4 -p /general/title_font -n -t string -s "$font"
|
||||||
font_new=$(xfconf-query -c xsettings -p /Gtk/FontName)
|
|
||||||
|
|
||||||
# Run sync_theme if the new system theme doesn't match the previous one
|
fi
|
||||||
[ "$theme_new" != "$theme_prev" ] && sync_theme
|
|
||||||
# Run sync_icon_theme if the new icon theme doesn't match the previous one
|
|
||||||
[ "$icon_theme_new" != "$icon_theme_prev" ] && sync_icon_theme
|
|
||||||
# If the new font doesn't match the previous one, apply the new font for the title of xfce windows
|
|
||||||
[ "$font_new" != "$font_prev" ] && xfconf-query -c xfwm4 -p /general/title_font -n -t string -s "$font_new"
|
|
||||||
|
|
||||||
# The new values become the previous values
|
done < <(xfconf-query -c xsettings -m)
|
||||||
theme_prev=$theme_new
|
|
||||||
icon_theme_prev=$icon_theme_new
|
|
||||||
font_prev=$font_new
|
|
||||||
|
|
||||||
sleep 3
|
|
||||||
done
|
|
Loading…
Reference in New Issue
Block a user
A minor thing: to replace
if;then;fi
withswitch;case
statement:More details and examples are here.
This just adds some structure and also an easier to update if some more settings changes will be necessary to subsctibe to. But I leave it up to you to decide, you can skip it if you want 😉
Oh of course it makes sense to use a case statement here, why didn't I think of it before? lol 😄
Oh, man.. Happens to me too quite often 😅