mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-07-04 14:23:16 +02:00
- Move fresh-install/ → scripts/single_use/fresh-install/ - Move hosts/ → scripts/periodic_background/hosts/ - Move i3-configuration/ → scripts/periodic_background/i3-configuration/ - Delete linux_configuration/LaTeX/, nix-poc/, report/ (dead dirs) - Move repo-root scripts/ → meta/scripts/ - Update root .pre-commit-config.yaml: scripts/ → meta/scripts/ (9 entries) - Update run.sh ARTIFACT_INIT_SCRIPT to meta/scripts/ - Update fresh-install/main.sh: hosts/install.sh + i3-configuration/install.sh paths - Update check_python_location.sh: add meta/scripts/ to exception list - Fix midnight flakiness in test_recent_workout_returns_true: use timezone-aware local noon instead of now-1h to avoid SQL date() boundary issues
32 lines
649 B
Bash
Executable File
32 lines
649 B
Bash
Executable File
#!/bin/bash
|
|
# i3blocks memory indicator, zero-fork per invocation via /proc/meminfo.
|
|
|
|
set -euo pipefail
|
|
|
|
format_mib() {
|
|
local mib=$1
|
|
if ((mib >= 1024)); then
|
|
printf '%d.%dGiB' "$((mib / 1024))" "$((((mib % 1024) * 10) / 1024))"
|
|
else
|
|
printf '%dMiB' "$mib"
|
|
fi
|
|
}
|
|
|
|
total_kib=0
|
|
available_kib=0
|
|
while IFS=' :' read -r key value _; do
|
|
case $key in
|
|
MemTotal)
|
|
total_kib=$value
|
|
;;
|
|
MemAvailable)
|
|
available_kib=$value
|
|
;;
|
|
esac
|
|
done < /proc/meminfo
|
|
|
|
used_mib=$(((total_kib - available_kib) / 1024))
|
|
total_mib=$((total_kib / 1024))
|
|
|
|
printf ' %s/%s\n' "$(format_mib "$used_mib")" "$(format_mib "$total_mib")"
|