Rewrite getgtk to also check DE

This commit is contained in:
Dylan 2016-02-08 23:29:48 +11:00
parent a272874833
commit f15f5728ea

91
fetch
View file

@ -1086,56 +1086,97 @@ getresolution () {
# }}} # }}}
# GTK Theme/Icons/Font {{{ # GTK Theme/Icons/Font New {{{
getgtk () { getgtk () {
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 esac
# Check for gtk2 theme # Current DE
if [ "$gtk2" == "on" ]; then desktop="$XDG_CURRENT_DESKTOP"
if [ -f "$HOME/.gtkrc-2.0" ]; then desktop=${desktop,,}
gtk2theme=$(grep "^[^#]*$name" "$HOME/.gtkrc-2.0") desktop=${desktop^}
elif [ -f "/etc/gtk-2.0/gtkrc" ]; then case "$desktop" in
gtk2theme=$(grep "^[^#]*$name" /etc/gtk-2.0/gtkrc) "Cinnamon")
fi if type -p gsettings >/dev/null 2>&1; then
gtk3theme=$(gsettings get org.cinnamon.desktop.interface $gsettings)
gtk3theme=${gtk3theme//"'"}
gtk2theme=${gtk3theme}
fi
;;
gtk2theme=${gtk2theme/${name}*=} "Gnome"* | "Unity"* | "Budgie")
gtk2theme=${gtk2theme//\"} if type -p gsettings >/dev/null 2>&1; then
fi gtk3theme=$(gsettings get org.gnome.desktop.interface $gsettings)
gtk3theme=${gtk3theme//"'"}
gtk2theme=${gtk3theme}
# Check for gtk3 theme elif type -p gconftool-2 >/dev/null 2>&1; then
if [ "$gtk3" == "on" ]; then gtk2theme=$(gconftool-2 -g /desktop/gnome/interface/$gconf)
if [ -f "$HOME/.config/gtk-3.0/settings.ini" ]; then fi
gtk3theme=$(grep "^[^#]*$name" "$HOME/.config/gtk-3.0/settings.ini") ;;
elif type -p gsettings >/dev/null 2>&1; then "Mate"*)
gtk3theme="$(gsettings get org.gnome.desktop.interface $gsettings)" gtk3theme=$(gsettings get org.mate.interface $gsettings)
gtk3theme=${gtk3theme//\'} gtk2theme=${gtk3theme}
;;
else "Xfce"*)
gtk3theme=$(grep "^[^#]*$name" /etc/gtk-3.0/settings.ini) if type -p xfconf-query >/dev/null 2>&1; then
fi gtk2Theme=$(xfconf-query -c xsettings -p /Net/$xfconf)
fi
;;
gtk3theme=${gtk3theme/${name}*=} *)
gtk3theme=${gtk3theme//\"} # Check for gtk2 theme
gtk3theme=${gtk3theme/[[:space:]]/ } if [ -f "$HOME/.gtkrc-2.0" ]; then
fi gtk2theme=$(grep "^[^#]*$name" "$HOME/.gtkrc-2.0")
elif [ -f "/etc/gtk-2.0/gtkrc" ]; then
gtk2theme=$(grep "^[^#]*$name" /etc/gtk-2.0/gtkrc)
fi
gtk2theme=${gtk2theme/${name}*=}
gtk2theme=${gtk2theme//\"}
# Check for gtk3 theme
if [ -f "$HOME/.config/gtk-3.0/settings.ini" ]; then
gtk3theme=$(grep "^[^#]*$name" "$HOME/.config/gtk-3.0/settings.ini")
elif type -p gsettings >/dev/null 2>&1; then
gtk3theme="$(gsettings get org.gnome.desktop.interface $gsettings)"
gtk3theme=${gtk3theme//\'}
else
gtk3theme=$(grep "^[^#]*$name" /etc/gtk-3.0/settings.ini)
fi
gtk3theme=${gtk3theme/${name}*=}
gtk3theme=${gtk3theme//\"}
gtk3theme=${gtk3theme/[[:space:]]/ }
;;
esac
# 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