voidrice/.local/bin/statusbar/disk

24 lines
570 B
Text
Raw Normal View History

#!/bin/sh
2019-11-23 21:23:24 +00:00
# Status bar module for disk space
2020-04-01 00:29:34 +00:00
# $1 should be drive mountpoint, otherwise assumed /.
2019-11-23 21:23:24 +00:00
2020-04-01 00:29:34 +00:00
location=${1:-/}
2019-11-23 21:23:24 +00:00
2020-04-01 00:29:34 +00:00
[ -d "$location" ] || exit
2019-11-23 21:23:24 +00:00
case $BLOCK_BUTTON in
2020-04-01 00:29:34 +00:00
1) notify-send "💽 Disk space" "$(df -h --output=target,used,size)" ;;
3) notify-send "💽 Disk module" "\- Shows used hard drive space.
2019-11-23 21:23:24 +00:00
- Click to show all disk info." ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
2019-11-23 21:23:24 +00:00
esac
2020-04-01 00:29:34 +00:00
case "$location" in
"/home"* ) icon="🏠" ;;
"/mnt"* ) icon="💾" ;;
*) icon="🖥";;
2020-04-01 00:29:34 +00:00
esac
printf "%s: %s\n" "$icon" "$(df -h "$location" | awk ' /[0-9]/ {print $3 "/" $2}')"