Files
env-ansible/files/dwm/storage.function

37 lines
908 B
Bash
Executable File

#!/usr/bin/env bash
# 2025-11-10 Hyperling
function storage-display {
location="$1"
style="$2"
if [[ -z "$location" ]]; then
echo "ERROR: Location must be passed. $location"
fi
if [[ "$style" == "%" || "$style" == "pct" || "$style" == "percent" ]]; then
df -h "$location" | tail -n 1 | awk '{print $5}'
elif [[ "$style" == "/" || "$style" == "use" || "$style" == "usage" ]]; then
df -h "$location" | tail -n 1 | awk '{print $3"/"$2}'
else
df -h "$location" | tail -n 1 | awk '{print $5" Free, "$3"/"$2" Used"}'
fi
}
alias storage='echo -n "Root: " && storage-display "/" && echo -n "Home: " && storage-display "/home"'
export dwm_storage_style="usage"
function storage-root {
storage-display / "$1"
}
function storage-root-dwm {
storage-root "$dwm_storage_style"
}
function storage-home {
storage-display /home "$1"
}
function storage-home-dwm {
storage-root "$dwm_storage_style"
}