Merge pull request #54 from dylanaraps/getgtk_rewrite

Rewrite GTK theme detection to also get correct DE theme.
This commit is contained in:
Dylan Araps 2016-02-09 09:11:58 +11:00
commit ccc43cbcae

55
fetch
View file

@ -1103,25 +1103,72 @@ getresolution () {
# GTK Theme/Icons/Font {{{ # GTK Theme/Icons/Font {{{
getgtk () { getgtk () {
# Fix weird output when the function
# is run multiple times.
unset gtk2theme gtk3theme
case "$1" in case "$1" in
theme) theme)
name="gtk-theme-name" name="gtk-theme-name"
gsettings="gtk-theme" gsettings="gtk-theme"
gconf="gtk_theme"
xfconf="ThemeName"
;; ;;
icons) icons)
name="gtk-icon-theme-name" name="gtk-icon-theme-name"
gsettings="icon-theme" gsettings="icon-theme"
gconf="icon_theme"
xfconf="IconThemeName"
;; ;;
font) font)
name="gtk-font-name" name="gtk-font-name"
gsettings="font-name" gsettings="font-name"
gconf="font_theme"
xfconf="FontName"
;;
esac
# Current DE
desktop="$XDG_CURRENT_DESKTOP"
desktop=${desktop,,}
desktop=${desktop^}
case "$desktop" in
"Cinnamon")
if type -p gsettings >/dev/null 2>&1; then
gtk3theme=$(gsettings get org.cinnamon.desktop.interface $gsettings)
gtk3theme=${gtk3theme//"'"}
gtk2theme=${gtk3theme}
fi
;;
"Gnome"* | "Unity"* | "Budgie")
if type -p gsettings >/dev/null 2>&1; then
gtk3theme=$(gsettings get org.gnome.desktop.interface $gsettings)
gtk3theme=${gtk3theme//"'"}
gtk2theme=${gtk3theme}
elif type -p gconftool-2 >/dev/null 2>&1; then
gtk2theme=$(gconftool-2 -g /desktop/gnome/interface/$gconf)
fi
;;
"Mate"*)
gtk3theme=$(gsettings get org.mate.interface $gsettings)
gtk2theme=${gtk3theme}
;;
"Xfce"*)
if type -p xfconf-query >/dev/null 2>&1; then
gtk2theme=$(xfconf-query -c xsettings -p /Net/$xfconf)
fi
;; ;;
esac esac
# Check for gtk2 theme # Check for gtk2 theme
if [ "$gtk2" == "on" ]; then if [ -z "$gtk2theme" ]; then
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")
@ -1134,7 +1181,7 @@ getgtk () {
fi fi
# Check for gtk3 theme # Check for gtk3 theme
if [ "$gtk3" == "on" ]; then if [ -z "$gtk3theme" ]; then
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")
@ -1151,6 +1198,10 @@ getgtk () {
gtk3theme=${gtk3theme/[[:space:]]/ } gtk3theme=${gtk3theme/[[:space:]]/ }
fi fi
# Toggle visibility of gtk themes.
[ "$gtk2" == "off" ] && unset gtk2theme
[ "$gtk3" == "off" ] && unset gtk3theme
# Format the string based on which themes exist # Format the string based on which themes exist
if [ "$gtk2theme" ] && [ "$gtk2theme" == "$gtk3theme" ]; then if [ "$gtk2theme" ] && [ "$gtk2theme" == "$gtk3theme" ]; then
gtk3theme+=" [GTK2/3]" gtk3theme+=" [GTK2/3]"