Guest User

Untitled

a guest
Feb 25th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. ###File name is free_m
  2. mem_free()
  3. {
  4. TYPE=free
  5.  
  6. awk -v type=$TYPE '
  7. /^MemTotal:/ {
  8. mem_total=$2
  9. }
  10. /^MemFree:/ {
  11. mem_free=$2
  12. }
  13. /^Buffers:/ {
  14. mem_free+=$2
  15. }
  16. /^Cached:/ {
  17. mem_free+=$2
  18. }
  19. /^SwapTotal:/ {
  20. swap_total=$2
  21. }
  22. /^SwapFree:/ {
  23. swap_free=$2
  24. }
  25. END {
  26. if (type == "swap") {
  27. free=swap_free/1024/1024
  28. used=(swap_total-swap_free)/1024/1024
  29. total=swap_total/1024/1024
  30. } else {
  31. free=mem_free/1024/1024
  32. used=(mem_total-mem_free)/1024/1024
  33. total=mem_total/1024/1024
  34. }
  35. pct=used/total*100
  36. # full text
  37. printf("%.1fG/%.1fG (%.f%%)\n", used, total, pct)
  38. # short text
  39. #printf("%.f%%\n", pct)
  40. # color
  41. if (pct > 90) {
  42. print("#FF0000\n")
  43. } else if (pct > 80) {
  44. print("#FFAE00\n")
  45. } else if (pct > 70) {
  46. print("#FFF600\n")
  47. }
  48. }
  49. ' /proc/meminfo
  50. }
  51.  
  52. ##### IN i3status_custom.sh
  53. #!/bin/bash
  54. i3status | while :
  55. #do
  56. # read line
  57. # echo "mystuff | $line" || exit 1
  58. #done
  59. source ~/.i3/free_m
  60. FREE_MEM=$(mem_free)
  61. do
  62. read line
  63. LGCODE=$(xset -q | grep "LED mask:" | awk '{ print $10 }')
  64. if [ $LGCODE == 00000000 ] || [ $LGCODE == 00000002 ]
  65. then
  66. echo "en | $FREE_MEM | $line" || exit 1
  67. fi
  68. if [ $LGCODE == 00001004 ]
  69. then
  70. echo "ru | $FREE_MEM | $line" || exit 1
  71. fi
  72. #echo "$dat | $line" || exit 1
  73. done
Add Comment
Please, Sign In to add comment