dotfiles/homes/x86_64-linux/christopher@cobalt/fixtures/eww/scripts/memory
Christopher Mühl 786af32daf
Publish my config
This is the result of ~100 commits to my NixOS config. Since I haven't
always used `agenix-rekey`, this is another initial commit so that none
of the secrets in my git history are leaked
2025-07-30 23:36:39 +02:00

19 lines
615 B
Bash
Executable file

#!/usr/bin/env bash
total="$(free -m | grep Mem | awk '{ print $2 }')"
used="$(free -m | grep Mem | awk '{ print $3 }')"
free=$(expr $total - $used)
total_human=$(numfmt --to=iec --format="%.1f" $(( $total * 1000 * 1000 )))
used_human=$(numfmt --to=iec --format="%.1f" $(( $used * 1000 * 1000 )))
free_human=$(numfmt --to=iec --format="%.1f" $(( $free * 1000 * 1000 )))
if [ "$1" = "total" ]; then
echo $total_human
elif [ "$1" = "used" ]; then
echo $used_human
elif [ "$1" = "free" ]; then
echo $free_human
elif [ "$1" = "json" ]; then
jo total=$total_human used=$used_human free=$free_human
fi