getgtk: Better theme detection
This commit is contained in:
parent
b30e6e6d18
commit
aa4395279d
32
fetch
32
fetch
|
@ -874,49 +874,49 @@ getresolution () {
|
||||||
|
|
||||||
getgtk () {
|
getgtk () {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
theme)
|
theme) name="gtk-theme-name" ;;
|
||||||
name="gtk-theme-name"
|
icons) name="gtk-icon-theme-name" ;;
|
||||||
type="gtk"
|
|
||||||
;;
|
|
||||||
|
|
||||||
icons)
|
|
||||||
name="gtk-icon-theme-name"
|
|
||||||
type="icon"
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# Check for gtk2 theme
|
||||||
if [ -f "$HOME/.gtkrc-2.0" ]; then
|
if [ -f "$HOME/.gtkrc-2.0" ]; then
|
||||||
gtk2theme=$(grep "^[^#]*$name" $HOME/.gtkrc-2.0)
|
gtk2theme=$(grep "^[^#]*$name" $HOME/.gtkrc-2.0)
|
||||||
|
elif [ -f "/etc/gtk-2.0/gtkrc" ]; then
|
||||||
|
gtk2theme=$(grep "^[^#]*$name" /etc/gtk-2.0/gtkrc)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Format the string
|
||||||
gtk2theme=${gtk2theme/${name}=/}
|
gtk2theme=${gtk2theme/${name}=/}
|
||||||
gtk2theme=${gtk2theme//\"/}
|
gtk2theme=${gtk2theme//\"/}
|
||||||
gtk2theme="$gtk2theme"
|
gtk2theme="$gtk2theme"
|
||||||
gtktheme="$gtk2theme [GTK2] "
|
gtktheme="$gtk2theme [GTK2] "
|
||||||
fi
|
|
||||||
|
|
||||||
|
# Check for gtk3 theme
|
||||||
if [ -f "$HOME/.config/gtk-3.0/settings.ini" ]; then
|
if [ -f "$HOME/.config/gtk-3.0/settings.ini" ]; then
|
||||||
gtk3theme=$(grep "^[^#]*$name" $HOME/.config/gtk-3.0/settings.ini)
|
gtk3theme=$(grep "^[^#]*$name" $HOME/.config/gtk-3.0/settings.ini)
|
||||||
|
else
|
||||||
|
gtk3theme=$(grep "^[^#]*$name" /etc/gtk-3.0/settings.ini)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Format the string
|
||||||
gtk3theme=${gtk3theme/${name}=/}
|
gtk3theme=${gtk3theme/${name}=/}
|
||||||
gtk3theme=${gtk3theme//\"/}
|
gtk3theme=${gtk3theme//\"/}
|
||||||
gtk3theme="$gtk3theme"
|
gtk3theme="$gtk3theme"
|
||||||
gtktheme="$gtk2theme $gtk3theme [GTK3]"
|
gtktheme="$gtk2theme $gtk3theme [GTK3]"
|
||||||
else
|
|
||||||
gtk3theme=$(gsettings get org.gnome.desktop.interface $type-theme 2>/dev/null)
|
|
||||||
gtktheme="$gtk3theme [GTK3] "
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
# Check to see if gtk2 and gtk3 theme are identical
|
||||||
if [ "$gtk2theme" ] && [ "$gtk2theme" == "$gtk3theme" ]; then
|
if [ "$gtk2theme" ] && [ "$gtk2theme" == "$gtk3theme" ]; then
|
||||||
gtktheme="$gtk2theme [GTK2/3]"
|
gtktheme="$gtk2theme [GTK2/3]"
|
||||||
elif [ -z "$gtk2theme" ] && [ -z "$gtk3theme" ]; then
|
elif [ -z "$gtk2theme" ] && [ -z "$gtk3theme" ]; then
|
||||||
gtktheme="None"
|
gtktheme="None"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Make the output shorter by removing "[GTKX]" from the string
|
||||||
if [ "$gtk_shorthand" == "on" ]; then
|
if [ "$gtk_shorthand" == "on" ]; then
|
||||||
gtktheme=${gtktheme/ [GTK2]/}
|
gtktheme=${gtktheme/ [GTK2]/}
|
||||||
gtktheme=${gtktheme/ [GTK3]/}
|
gtktheme=${gtktheme/ [GTK3]/}
|
||||||
gtktheme=${gtktheme/ [GTK2\/\3\]/}
|
gtktheme=${gtktheme/ [GTK2\/\3\]/}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
gtktheme=${gtktheme//\'}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getgtktheme () {
|
getgtktheme () {
|
||||||
|
|
Reference in New Issue