Added experimental disk usage

This commit is contained in:
Dylan 2016-01-26 21:25:28 +11:00
parent 2b04747804
commit 21edcc0eb9

27
fetch
View file

@ -55,7 +55,7 @@ export LANGUAGE=C
# "gtkicons" "cpu" "gpu" "memory" "cols"
#
# Info functions that are disabled by default are:
# "resolution" "song" "visualstyle" "font"
# "resolution" "song" "visualstyle" "font" "disk"
#
# See this wiki page for more info:
# https://github.com/dylanaraps/fetch/wiki/Customizing-Info
@ -705,7 +705,7 @@ getcpu () {
getgpu () {
case "$os" in
"Linux")
gpu="$(lspci | grep "VGA")"
gpu="$(lspci | grep -F "VGA")"
gpu=${gpu/* VGA compatible controller: }
gpu=${gpu/(rev*)}
@ -1005,6 +1005,29 @@ getgtkfont () {
gtkfont="$gtktheme"
}
getdisk () {
if type -p df >/dev/null 2>&1; then
# df flags
case "$os" in
"Linux") df_flags="-h --total" ;;
"Mac OS X") df_flags="-H /" ;;
*"BSD") df_flags="-h -c" ;;
esac
# Get the disk info
disk=$(df $df_flags 2>/dev/null | awk '/total/ {printf $2 ":" $3 ":" $5}')
# Format the output
disk_used=${disk#*:}
disk_used=${disk_used%%:*}
disk_total=${disk%%:*}
disk_total_per=${disk#*:*:}
# Put it all together
disk="${disk_used} / ${disk_total} (${disk_total_per})"
fi
}
getcols () {
if [ "$color_blocks" == "on" ]; then
printf "${padding}%s"