dot/.local/bin/i3scripts/contrib/memory

47 lines
719 B
Plaintext
Raw Normal View History

2020-02-19 15:55:35 +00:00
#!/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