Compare commits
No commits in common. "104755ce40bac9cb816941e7244fe402aa632ab7" and "c24e3da46eac709acd75c3fbfd90aad35e107ad2" have entirely different histories.
104755ce40
...
c24e3da46e
|
@ -1,5 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
sync_theme() {
|
while read -r line; do
|
||||||
|
|
||||||
|
case "$line" in
|
||||||
|
# When the system theme has been changed
|
||||||
|
'set: /Net/ThemeName')
|
||||||
# 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,53 +14,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"
|
||||||
}
|
;;
|
||||||
|
# When the icon theme has been changed
|
||||||
setvalue() {
|
'set: /Net/IconThemeName')
|
||||||
grep -qz "^\[Appearance\][^\[]*$1=$2" "$file" && return
|
|
||||||
if grep -qz "^\[Appearance\][^\[]*$1=" "$file"; then
|
|
||||||
sed -i "/\[Appearance\]/,/^\s*$1=/{s/^\s*$1=.*$/$1=$2/}" "$file"
|
|
||||||
else
|
|
||||||
sed -i "/\[Appearance\]/a $1=$2" "$file"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
sync_icon_theme() {
|
|
||||||
# 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
|
||||||
for file in "$HOME"/.config/qt5ct/qt5ct.conf "$HOME"/.config/qt6ct/qt6ct.conf; do
|
sed -i "s/^icon_theme=.*$/icon_theme=$icon_theme/" "$HOME"/.config/qt5ct/qt5ct.conf
|
||||||
# Create the config directory
|
sed -i "s/^icon_theme=.*$/icon_theme=$icon_theme/" "$HOME"/.config/qt6ct/qt6ct.conf
|
||||||
dir=$(dirname "$file")
|
;;
|
||||||
mkdir -p "$dir" || { echo "failed to make directory $dir"; continue; }
|
# When the system font has been changed
|
||||||
# Create the config file appropriately
|
'set: /Gtk/FontName')
|
||||||
if grep -q '^\[Appearance\]' "$file"; then
|
|
||||||
setvalue 'icon_theme' "$icon_theme"
|
|
||||||
setvalue 'style' 'gtk2'
|
|
||||||
elif grep -q '\S' "$file"; then
|
|
||||||
tail -n1 "$file" | grep -qx '\s*' && begin='' || begin='\n'
|
|
||||||
printf '%b[Appearance]\nicon_theme=%s\nstyle=gtk2\n' "$begin" "$icon_theme" >> "$file"
|
|
||||||
else
|
|
||||||
printf '[Appearance]\nicon_theme=%s\nstyle=gtk2\n' "$icon_theme" > "$file"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
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"
|
||||||
}
|
;;
|
||||||
|
|
||||||
sync_theme
|
|
||||||
sync_icon_theme
|
|
||||||
sync_font
|
|
||||||
|
|
||||||
while read -r line; do
|
|
||||||
case "$line" in
|
|
||||||
'set: /Net/ThemeName') sync_theme ;;
|
|
||||||
'set: /Net/IconThemeName') sync_icon_theme ;;
|
|
||||||
'set: /Gtk/FontName') sync_font ;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
done < <(xfconf-query -c xsettings -m)
|
done < <(xfconf-query -c xsettings -m)
|
Loading…
Reference in New Issue
Block a user