dotfiles/homes/x86_64-linux/christopher@cobalt/config/eww/scripts/memory
Christopher Mühl d20c9ac3bd
Move eww config
2025-08-04 18:21:31 +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