You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dot/.local/bin/i3scripts/contrib/memory

47 lines
719 B

#!/usr/bin/env bash
################################
# Shows info about the RAM
#
# Dependencies:
# - [notify-send]
#
# @return {Number(%)}: RAM usage
################################
dir=$(dirname $0)
source $dir/util.sh
full=""
short=""
status=0
exec 6< /proc/meminfo
read a total b <&6
read a free b <&6
read a b c <&6
read a buffer b <&6
read a cached b <&6
MEM=$(calc "100 * ($total - ($free + $buffer + $cached)) / $total")
full="$MEM%"
short=$full
if [ $MEM -ge 80 ]; then
status=33
fi
case $BLOCK_BUTTON in
# right click: show packages
3)
n=16
summary=$(ps -eo pmem,pcpu,pid,comm --sort=-pmem | head -$n)
notify-send "Top $n RAM-eaters" "$summary"
;;
esac
echo $full
echo $short
exit $status