Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###File name is free_m
- mem_free()
- {
- TYPE=free
- awk -v type=$TYPE '
- /^MemTotal:/ {
- mem_total=$2
- }
- /^MemFree:/ {
- mem_free=$2
- }
- /^Buffers:/ {
- mem_free+=$2
- }
- /^Cached:/ {
- mem_free+=$2
- }
- /^SwapTotal:/ {
- swap_total=$2
- }
- /^SwapFree:/ {
- swap_free=$2
- }
- END {
- if (type == "swap") {
- free=swap_free/1024/1024
- used=(swap_total-swap_free)/1024/1024
- total=swap_total/1024/1024
- } else {
- free=mem_free/1024/1024
- used=(mem_total-mem_free)/1024/1024
- total=mem_total/1024/1024
- }
- pct=used/total*100
- # full text
- printf("%.1fG/%.1fG (%.f%%)\n", used, total, pct)
- # short text
- #printf("%.f%%\n", pct)
- # color
- if (pct > 90) {
- print("#FF0000\n")
- } else if (pct > 80) {
- print("#FFAE00\n")
- } else if (pct > 70) {
- print("#FFF600\n")
- }
- }
- ' /proc/meminfo
- }
- ##### IN i3status_custom.sh
- #!/bin/bash
- i3status | while :
- #do
- # read line
- # echo "mystuff | $line" || exit 1
- #done
- source ~/.i3/free_m
- FREE_MEM=$(mem_free)
- do
- read line
- LGCODE=$(xset -q | grep "LED mask:" | awk '{ print $10 }')
- if [ $LGCODE == 00000000 ] || [ $LGCODE == 00000002 ]
- then
- echo "en | $FREE_MEM | $line" || exit 1
- fi
- if [ $LGCODE == 00001004 ]
- then
- echo "ru | $FREE_MEM | $line" || exit 1
- fi
- #echo "$dat | $line" || exit 1
- done
Add Comment
Please, Sign In to add comment