No need to edit qt configuration files anymore
This commit is contained in:
parent
61afd40bfa
commit
d909158646
|
@ -12,36 +12,6 @@ sync_theme() {
|
||||||
gsettings set org.gnome.desktop.interface gtk-theme "$theme"
|
gsettings set org.gnome.desktop.interface gtk-theme "$theme"
|
||||||
}
|
}
|
||||||
|
|
||||||
setvalue() {
|
|
||||||
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
|
|
||||||
icon_theme=$(xfconf-query -c xsettings -p /Net/IconThemeName)
|
|
||||||
# Apply the same theme in qt5ct and qt6ct configuration
|
|
||||||
for file in "$HOME"/.config/qt5ct/qt5ct.conf "$HOME"/.config/qt6ct/qt6ct.conf; do
|
|
||||||
# Create the config directory
|
|
||||||
dir=$(dirname "$file")
|
|
||||||
mkdir -p "$dir" || { echo "failed to make directory $dir"; continue; }
|
|
||||||
# Create the config file appropriately
|
|
||||||
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() {
|
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)
|
||||||
|
@ -50,13 +20,11 @@ sync_font() {
|
||||||
}
|
}
|
||||||
|
|
||||||
sync_theme
|
sync_theme
|
||||||
sync_icon_theme
|
|
||||||
sync_font
|
sync_font
|
||||||
|
|
||||||
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 ;;
|
||||||
'set: /Net/IconThemeName') sync_icon_theme ;;
|
|
||||||
'set: /Gtk/FontName') sync_font ;;
|
'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