Add Waybar disk list via HM

This commit is contained in:
2026-02-04 12:35:23 -08:00
parent 0d47dba590
commit 6d283347ee
2 changed files with 50 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
#!/usr/bin/env bash
set -euo pipefail
config_dir="${XDG_CONFIG_HOME:-$HOME/.config}/waybar"
list_file="${config_dir}/disks"
mounts=()
if [[ -n "${WAYBAR_DISKS:-}" ]]; then
# Accept comma or space separated values.
IFS=', ' read -r -a mounts <<< "${WAYBAR_DISKS//:/,}"
elif [[ -f "$list_file" ]]; then
while IFS= read -r line; do
line="${line%%#*}"
line="${line#"${line%%[![:space:]]*}"}"
line="${line%"${line##*[![:space:]]}"}"
[[ -z "$line" ]] && continue
mounts+=("$line")
done < "$list_file"
fi
if [[ ${#mounts[@]} -eq 0 ]]; then
mounts=("/")
fi
items=()
for mount in "${mounts[@]}"; do
if df_out=$(df -h --output=avail,target "$mount" 2>/dev/null | awk 'NR==2 {print $2, $1}'); then
items+=("$df_out")
fi
done
if [[ ${#items[@]} -eq 0 ]]; then
exit 0
fi
output=""
for item in "${items[@]}"; do
if [[ -n "$output" ]]; then
output+=" | "
fi
output+="$item"
done
printf '%s\n' "$output"

View File

@@ -76,6 +76,7 @@
swapDevices = [
{ device = "/dev/disk/by-uuid/27f277a0-b552-43a0-904d-625e48922bb9"; }
{ device = "/swapfile"; size = 16384; } # size is in MiB (adds 16 GiB)
];
networking.hostName = "strixi-minaj";
@@ -86,6 +87,10 @@
home-manager.sharedModules = [
{
home.stateVersion = "23.05";
xdg.configFile."waybar/disks".text = ''
# One mountpoint per line (comments with # are ignored).
/
'';
}
];