#!/bin/sh -e # # disk: print the current disk space and usage # Copyright (C) 2008 Canonical Ltd. # # Authors: Dustin Kirkland # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . PKG="byobu" color 2>/dev/null || color() { true; } if [ "$1" = "--detail" ]; then df -h -P exit 0 fi # Default to /, but let users override MP="/" [ -n "$MONITORED_DISK" ] && MP="$MONITORED_DISK" case $MP in /dev/*) MP=$(grep "$MP" /proc/mounts | awk '{print $2}') ;; esac disk=$(df -h -P "$MP" 2>/dev/null || df -h "$MP") disk=$(echo "$disk" | tail -n 1 | awk '{print $2 " " $5}' | sed "s/\([^0-9\. ]\)/ \1/g" | awk '{printf "%d%sB,%d%%", $1, $2, $3}') printf "$(color M W)%s$(color -) " "$disk" | sed "s/\([0-9]\+\)/$(color -)$(color b M W)\1$(color -)$(color M W)/g"