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