config/.local/bin/status-disk
2025-12-12 18:05:35 +10:30

37 lines
946 B
Bash
Executable File

#!/bin/bash
homeval=$(df -h -B 1048576 | grep "/home")
case $BUTTON in
1) notify-send "Disk space" "$(df -h --output=target,used,size --type=ext4 --type=nfs4)" ;;
3) notify-send "Disk module" "Shows disk usage information
- Click to show all disk info." ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
if [[ -n $homeval ]]; then
homefreemb=$(echo "$homeval" | awk -F ' ' '{ print $4 }')
homefreegb=$(echo "$homeval" | awk -F ' ' '{ print $4/1024 }')
fi
rootfreemb=$(df -h -B 1048576 | grep "/$" | awk -F ' ' '{ print $4 }')
rootfreegb=$(df -h -B 1048576 | grep "/$" | awk -F ' ' '{ print $4/1024 }')
out=""
if [ "$rootfreemb" -lt 1024 ]; then
out="$out / $(printf "%0.2fMb" "$rootfreemb")"
else
out="$out / $(printf "%0.2fGb" "$rootfreegb")"
fi
if [[ -n $homeval ]]; then
if [ "$homefreemb" -lt 1024 ]; then
out="$out ~ $(printf "%0.2fMb" "$homefreemb")"
else
out="$out ~ $(printf "%0.2fGb" "$homefreegb")"
fi
fi
echo "$out"