From cbc33486f7ae47792e38fffeecb32ef09c3355d2 Mon Sep 17 00:00:00 2001 From: Dylan Date: Tue, 9 Feb 2016 02:21:12 +1100 Subject: [PATCH] If the DE detection fails fallback to the generic theme detection --- fetch | 62 +++++++++++++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/fetch b/fetch index 6bb227d5..ef87ce1c 100755 --- a/fetch +++ b/fetch @@ -1089,6 +1089,10 @@ getresolution () { # GTK Theme/Icons/Font {{{ getgtk () { + # Fix weird output when the function + # is run multiple times. + unset gtk2theme gtk3theme + case "$1" in theme) name="gtk-theme-name" @@ -1147,37 +1151,37 @@ getgtk () { gtk2theme=$(xfconf-query -c xsettings -p /Net/$xfconf) fi ;; - - *) - # Check for gtk2 theme - if [ -f "$HOME/.gtkrc-2.0" ]; then - 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 + if [ -z "$gtk2theme" ] && [ -z "$gtk3theme" ]; then + # Check for gtk2 theme + if [ -f "$HOME/.gtkrc-2.0" ]; then + 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:]]/ } + fi + # Toggle visibility of gtk themes. [ "$gtk2" == "off" ] && unset gtk2theme [ "$gtk3" == "off" ] && unset gtk3theme