simpliffied code plus fix for the libadwaita theming
This commit is contained in:
parent
68321075f6
commit
b521a23108
|
@ -1,20 +1,36 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
sync_theme() {
|
sync_theme() {
|
||||||
# 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
|
|
||||||
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)
|
# Enable syncing the current theme with xfwm4
|
||||||
# If a match is not found then use the Default theme
|
if [ "$(xfconf-query -c xsettings -p /Xfce/SyncThemes)" != 'true' ]; then
|
||||||
[ -z "$xfwm4_theme" ] && xfwm4_theme='Default'
|
xfconf-query -c xsettings -p /Xfce/SyncThemes -n -t bool -s true
|
||||||
# Apply the xfwm4 theme
|
fi
|
||||||
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"
|
||||||
|
|
||||||
|
# Apply the current theme for GTK apps in flatpak
|
||||||
|
|
||||||
|
# Define the path to the flatpak override directory
|
||||||
|
flatpak_override_dir="$HOME/.local/share/flatpak/overrides"
|
||||||
|
|
||||||
|
# Create the directory if it doesn't exist
|
||||||
|
if [ ! -d "$flatpak_override_dir" ]; then
|
||||||
|
mkdir -p "$flatpak_override_dir" || { echo 'Failed creating directory!'; return 1; }
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Write the theme configuration to the global override file
|
||||||
|
echo "[Environment]
|
||||||
|
GTK_THEME=$theme" > "$flatpak_override_dir/global"
|
||||||
}
|
}
|
||||||
|
|
||||||
sync_font() {
|
sync_font() {
|
||||||
# Get the current system font
|
# Get the current system font
|
||||||
font=$(xfconf-query -c xsettings -p /Gtk/FontName)
|
font=$(xfconf-query -c xsettings -p /Gtk/FontName)
|
||||||
|
|
||||||
# Apply the same font for the title of xfce windows
|
# Apply the same font for the title of xfce windows
|
||||||
xfconf-query -c xfwm4 -p /general/title_font -n -t string -s "$font"
|
xfconf-query -c xfwm4 -p /general/title_font -n -t string -s "$font"
|
||||||
}
|
}
|
||||||
|
@ -22,6 +38,7 @@ sync_font() {
|
||||||
sync_theme
|
sync_theme
|
||||||
sync_font
|
sync_font
|
||||||
|
|
||||||
|
# Monitor when the user changes their system theme or font in XFCE and sync them as needed
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
case "$line" in
|
case "$line" in
|
||||||
'set: /Net/ThemeName') sync_theme ;;
|
'set: /Net/ThemeName') sync_theme ;;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user