From f15f5728eacab105d316a51e0cb2ede0e5c7a427 Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 8 Feb 2016 23:29:48 +1100 Subject: [PATCH 1/6] Rewrite getgtk to also check DE --- fetch | 91 +++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 66 insertions(+), 25 deletions(-) diff --git a/fetch b/fetch index 2404f19f..9df885c9 100755 --- a/fetch +++ b/fetch @@ -1086,56 +1086,97 @@ getresolution () { # }}} -# GTK Theme/Icons/Font {{{ +# GTK Theme/Icons/Font New {{{ getgtk () { case "$1" in theme) name="gtk-theme-name" gsettings="gtk-theme" + gconf="gtk_theme" + xfconf="ThemeName" ;; icons) name="gtk-icon-theme-name" gsettings="icon-theme" + gconf="icon_theme" + xfconf="IconThemeName" ;; font) name="gtk-font-name" gsettings="font-name" + gconf="font_theme" + xfconf="FontName" ;; esac - # Check for gtk2 theme - if [ "$gtk2" == "on" ]; then - if [ -f "$HOME/.gtkrc-2.0" ]; then - gtk2theme=$(grep "^[^#]*$name" "$HOME/.gtkrc-2.0") + # Current DE + desktop="$XDG_CURRENT_DESKTOP" + desktop=${desktop,,} + desktop=${desktop^} - elif [ -f "/etc/gtk-2.0/gtkrc" ]; then - gtk2theme=$(grep "^[^#]*$name" /etc/gtk-2.0/gtkrc) - fi + 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 + ;; - gtk2theme=${gtk2theme/${name}*=} - gtk2theme=${gtk2theme//\"} - 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} - # Check for gtk3 theme - if [ "$gtk3" == "on" ]; then - if [ -f "$HOME/.config/gtk-3.0/settings.ini" ]; then - gtk3theme=$(grep "^[^#]*$name" "$HOME/.config/gtk-3.0/settings.ini") + elif type -p gconftool-2 >/dev/null 2>&1; then + gtk2theme=$(gconftool-2 -g /desktop/gnome/interface/$gconf) + fi + ;; - elif type -p gsettings >/dev/null 2>&1; then - gtk3theme="$(gsettings get org.gnome.desktop.interface $gsettings)" - gtk3theme=${gtk3theme//\'} + "Mate"*) + gtk3theme=$(gsettings get org.mate.interface $gsettings) + gtk2theme=${gtk3theme} + ;; - else - gtk3theme=$(grep "^[^#]*$name" /etc/gtk-3.0/settings.ini) - fi + "Xfce"*) + if type -p xfconf-query >/dev/null 2>&1; then + gtk2Theme=$(xfconf-query -c xsettings -p /Net/$xfconf) + fi + ;; - gtk3theme=${gtk3theme/${name}*=} - gtk3theme=${gtk3theme//\"} - gtk3theme=${gtk3theme/[[:space:]]/ } - 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 # Format the string based on which themes exist if [ "$gtk2theme" ] && [ "$gtk2theme" == "$gtk3theme" ]; then From 438d5e05424195002cc7d72522dbef8825d123c8 Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 8 Feb 2016 23:37:14 +1100 Subject: [PATCH 2/6] GTK: Fix xfce case --- fetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fetch b/fetch index 9df885c9..6740b17a 100755 --- a/fetch +++ b/fetch @@ -1144,7 +1144,7 @@ getgtk () { "Xfce"*) if type -p xfconf-query >/dev/null 2>&1; then - gtk2Theme=$(xfconf-query -c xsettings -p /Net/$xfconf) + gtk2theme=$(xfconf-query -c xsettings -p /Net/$xfconf) fi ;; From 5446b6afd53c38625f800df72242d4d1ba559231 Mon Sep 17 00:00:00 2001 From: Dylan Date: Tue, 9 Feb 2016 00:47:51 +1100 Subject: [PATCH 3/6] Add back support for '$gtk2/3' --- fetch | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fetch b/fetch index 6740b17a..94aff8f0 100755 --- a/fetch +++ b/fetch @@ -1178,6 +1178,10 @@ getgtk () { ;; esac + # Toggle visibility of gtk themes. + [ "$gtk2" == "off" ] && unset gtk2theme + [ "$gtk3" == "off" ] && unset gtk3theme + # Format the string based on which themes exist if [ "$gtk2theme" ] && [ "$gtk2theme" == "$gtk3theme" ]; then gtk3theme+=" [GTK2/3]" From caf55803f31e7a84f8ae649dd2264a51eecf0c51 Mon Sep 17 00:00:00 2001 From: Dylan Date: Tue, 9 Feb 2016 01:06:54 +1100 Subject: [PATCH 4/6] Remove new from comment --- fetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fetch b/fetch index 94aff8f0..6bb227d5 100755 --- a/fetch +++ b/fetch @@ -1086,7 +1086,7 @@ getresolution () { # }}} -# GTK Theme/Icons/Font New {{{ +# GTK Theme/Icons/Font {{{ getgtk () { case "$1" in From cbc33486f7ae47792e38fffeecb32ef09c3355d2 Mon Sep 17 00:00:00 2001 From: Dylan Date: Tue, 9 Feb 2016 02:21:12 +1100 Subject: [PATCH 5/6] 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 From 5e8953c7fa4021a5d2770a100e43d3d7d181e13e Mon Sep 17 00:00:00 2001 From: Dylan Date: Tue, 9 Feb 2016 07:16:15 +1100 Subject: [PATCH 6/6] We now check for GTK theme by GTK version --- fetch | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fetch b/fetch index ef87ce1c..3e4ef546 100755 --- a/fetch +++ b/fetch @@ -1153,8 +1153,8 @@ getgtk () { ;; esac - if [ -z "$gtk2theme" ] && [ -z "$gtk3theme" ]; then - # Check for gtk2 theme + # Check for gtk2 theme + if [ -z "$gtk2theme" ]; then if [ -f "$HOME/.gtkrc-2.0" ]; then gtk2theme=$(grep "^[^#]*$name" "$HOME/.gtkrc-2.0") @@ -1164,8 +1164,10 @@ getgtk () { gtk2theme=${gtk2theme/${name}*=} gtk2theme=${gtk2theme//\"} + fi - # Check for gtk3 theme + # Check for gtk3 theme + if [ -z "$gtk3theme" ]; then if [ -f "$HOME/.config/gtk-3.0/settings.ini" ]; then gtk3theme=$(grep "^[^#]*$name" "$HOME/.config/gtk-3.0/settings.ini")