diff --git a/bin/periodic/fix-theming b/bin/periodic/fix-theming index 04f9fc2..1d6a7ea 100755 --- a/bin/periodic/fix-theming +++ b/bin/periodic/fix-theming @@ -11,6 +11,9 @@ flatpak_icons_dir="$HOME/.icons" mkdir -p "$flatpak_themes_dir" "$flatpak_icons_dir" || { echo "failed to make directories $flatpak_themes_dir & $flatpak_icons_dir"; exit 1; } +# Enable option for syncing the current theme with XFWM theme if not already enabled +[ "$(xfconf-query -c xsettings -p /Xfce/SyncThemes)" != 'true' ] && xfconf-query -c xsettings -p /Xfce/SyncThemes -n -t bool -s true + xdg_directory_lookup() { # Go through each item in $XDG_DATA_DIRS and find the subdirectory $1 while read -r dir; do @@ -77,17 +80,18 @@ sync_theme() { # Get the current system theme current_theme=$(xfconf-query -c xsettings -p /Net/ThemeName) - # Enable syncing the current theme with XFWM theme if not already enabled - [ "$(xfconf-query -c xsettings -p /Xfce/SyncThemes)" != 'true' ] && xfconf-query -c xsettings -p /Xfce/SyncThemes -n -t bool -s true # Apply the current theme with gsettings gsettings set org.gnome.desktop.interface gtk-theme "$current_theme" + # Apply the current theme for GTK and Libadwaita apps on flatpak flatpak override --user --env=GTK_THEME="$current_theme" + # Apply the current theme for XFWM + xfconf-query -c xfwm4 -p /general/theme -n -t string -s "$current_theme" + # Change XFWM theme and mouse cursor size according to the user's highDPI setting hdpi_theme_fix - # Cleanup flatpak_themes_dir rm -rf "${flatpak_themes_dir:?}"/* @@ -98,20 +102,6 @@ sync_theme() { rsync -av --delete --progress "$current_theme_dir" "$flatpak_themes_dir" } -sync_icons() { - # Get the current icon theme - current_icon_theme=$(xfconf-query -c xsettings -p /Net/IconThemeName) - - # Cleanup flatpak_icons_dir - rm -rf "${flatpak_icons_dir:?}"/* - - # Find the directory where the current icon theme is stored - current_icon_theme_dir=$(xdg_directory_lookup "icons/$current_icon_theme") - # Copy/sync current_icon_theme_dir to flatpak_icons_dir - [ -d "$current_icon_theme_dir" ] && - rsync -av --delete --progress "$current_icon_theme_dir" "$flatpak_icons_dir" -} - sync_font() { # Get the current system font font=$(xfconf-query -c xsettings -p /Gtk/FontName) @@ -121,7 +111,6 @@ sync_font() { # Initial synchronization sync_theme -sync_icons sync_font # Monitor when the user changes their system theme or icons or font in XFCE and sync them as needed @@ -129,7 +118,6 @@ while read -r line; do case "$line" in 'set: /Net/ThemeName') sync_theme ;; 'set: /Gdk/WindowScalingFactor') hdpi_theme_fix ;; - 'set: /Net/IconThemeName') sync_icons ;; 'set: /Gtk/FontName') sync_font ;; esac done < <(xfconf-query -c xsettings -m)