~kris/dots

srice

srice/.local/bin/statusbar/sb-disk -rw-r--r-- 877 bytes
e98f3b03 — Kris Yotam chore: sync local state after restore (push updates, no pull) a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh

# Status bar module for disk space
# Automatically detects /home if separate partition, otherwise uses /
# Can override with $1 argument

# Smart default: use /home if it's a separate partition, else /
if [ -n "$1" ]; then
    location="$1"
elif df /home 2>/dev/null | grep -q "^/dev" && [ "$(df / --output=source | tail -1)" != "$(df /home --output=source | tail -1)" ]; then
    location="/home"
else
    location="/"
fi

[ -d "$location" ] || exit

case $BLOCK_BUTTON in
    1) notify-send "󰋊 Disk space" "$(df -h --output=target,used,size,avail,pcent /home / 2>/dev/null | head -5)" ;;
    3) notify-send "󰋊 Disk module" "Shows disk space for $location
- Left click for full disk info
- Currently monitoring: $location" ;;
    6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;;
esac

printf "󰋊  %s\n" "$(df -h "$location" | awk '/[0-9]/ {print $3 "/" $2}')"