Fixed gtk3 always printing theme instead of icons/font etc. Added new function 'gtkfont' to get the gtk theme's font, it's disabled by default and can be enabled like any other info line. Also sped up memory function on Linux.

This commit is contained in:
Dylan 2016-01-26 12:48:40 +11:00
parent 04280a688e
commit 0e83e2099d

36
fetch
View file

@ -52,10 +52,10 @@ export LANGUAGE=C
# Info functions enabled by default are: # Info functions enabled by default are:
# "title" "distro" "kernel" "uptime" "packages" # "title" "distro" "kernel" "uptime" "packages"
# "shell" "resolution" "windowmanager" "gtktheme" # "shell" "resolution" "windowmanager" "gtktheme"
# "gtkicons" "cpu" "memory" "cols" # "gtkicons" "cpu" "gpu" "memory" "cols"
# #
# Info functions that are disabled by default are: # Info functions that are disabled by default are:
# "resolution" "song" "visualstyle" "gpu" # "resolution" "song" "visualstyle" "font"
# #
# See this wiki page for more info: # See this wiki page for more info:
# https://github.com/dylanaraps/fetch/wiki/Customizing-Info # https://github.com/dylanaraps/fetch/wiki/Customizing-Info
@ -800,20 +800,15 @@ getmemory () {
# Read first 3 lines # Read first 3 lines
exec 6< /proc/meminfo exec 6< /proc/meminfo
read -r memtotal <&6 read -r memtotal <&6
read -r memfree <&6 read -r memfree <&6 # We don't actually use this var
read -r memavail <&6 read -r memavail <&6
exec 6<&- exec 6<&-
# Do some substitution on each line # Do some substitution on each line
memtotal=${memtotal/MemTotal:/} memtotal=${memtotal/MemTotal:/}
memtotal=${memtotal/kB*/} memtotal=${memtotal/kB*/}
memtotal=${memtotal// /}
memfree=${memfree/MemFree:/}
memfree=${memfree/kB*/}
memfree=${memfree// /}
memavail=${memavail/MemAvailable:/} memavail=${memavail/MemAvailable:/}
memavail=${memavail/kB*/} memavail=${memavail/kB*/}
memavail=${memavail// /}
memused=$((memtotal - memavail)) memused=$((memtotal - memavail))
memory="$((memused / 1024))MB / $((memtotal / 1024))MB" memory="$((memused / 1024))MB / $((memtotal / 1024))MB"
@ -920,8 +915,20 @@ getresolution () {
getgtk () { getgtk () {
case "$1" in case "$1" in
theme) name="gtk-theme-name" ;; theme)
icons) name="gtk-icon-theme-name" ;; name="gtk-theme-name"
gsettings="gtk-theme"
;;
icons)
name="gtk-icon-theme-name"
gsettings="icon-theme"
;;
font)
name="gtk-font-name"
gsettings="font-name"
;;
esac esac
# Check for gtk2 theme # Check for gtk2 theme
@ -934,7 +941,7 @@ getgtk () {
# Check for gtk3 theme # Check for gtk3 theme
if type -p gsettings >/dev/null 2>&1; then if type -p gsettings >/dev/null 2>&1; then
gtk3theme="$(gsettings get org.gnome.desktop.interface gtk-theme)" gtk3theme="$(gsettings get org.gnome.desktop.interface $gsettings)"
gtk3theme=${gtk3theme//\'} gtk3theme=${gtk3theme//\'}
elif [ -f "$HOME/.config/gtk-3.0/settings.ini" ]; then elif [ -f "$HOME/.config/gtk-3.0/settings.ini" ]; then
@ -954,7 +961,7 @@ getgtk () {
# Format the string # Format the string
gtk3theme=${gtk3theme/${name}*=/} gtk3theme=${gtk3theme/${name}*=/}
gtk3theme=${gtk3theme//\"/} gtk3theme=${gtk3theme//\"/}
gtk3theme=${gtk3theme/[[:space:]]} gtk3theme=${gtk3theme/[[:space:]]/ }
gtktheme="${gtk2theme}${gtk3theme} [GTK3] " gtktheme="${gtk2theme}${gtk3theme} [GTK3] "
# Check to see if gtk2 and gtk3 theme are identical # Check to see if gtk2 and gtk3 theme are identical
@ -992,6 +999,11 @@ getgtkicons () {
gtkicons="$gtktheme" gtkicons="$gtktheme"
} }
getgtkfont () {
getgtk font
gtkfont="$gtktheme"
}
getcols () { getcols () {
if [ "$color_blocks" == "on" ]; then if [ "$color_blocks" == "on" ]; then
printf "${padding}%s" printf "${padding}%s"