diff --git a/.config/conky/scripts/mem_info.sh b/.config/conky/scripts/mem_info.sh index 50c20db..ff29bc7 100755 --- a/.config/conky/scripts/mem_info.sh +++ b/.config/conky/scripts/mem_info.sh @@ -1,6 +1,7 @@ #!/bin/bash # Configuration variables +python_bin="/usr/bin/python3" memfile="/proc/meminfo" size="G" # Change to M for MiB @@ -12,7 +13,11 @@ memActive=$(expr ${memTotal} - ${memActive}) # Variables to calculate memTotalM=$(expr ${memTotal} / 1024 ) memActiveM=$(expr ${memActive} / 1024) -if [ -f /usr/bin/calc ] ; then +if [ -f ${python_bin} ] ; then + memPercentage=$(echo "n=${memActive}/${memTotal}*100 ; print(n)" | ${python_bin}) + memTotalG=$(echo "n=${memTotalM}/1024 ; print(n)" | ${python_bin} | tr -s " " | cut -c1-4) + memActiveG=$(echo "n=${memActiveM}/1024 ; print(n)" | ${python_bin} | tr -s " " | cut -c1-4) +elif [ -f /usr/bin/calc ] ; then memPercentage=$(calc ${memActive} / ${memTotal} \* 100) memTotalG=$(calc ${memTotalM} / 1024 | tr -s " " | cut -c1-5) memActiveG=$(calc ${memActiveM} / 1024 | tr -s " " | cut -c1-5) diff --git a/.config/dwm/scripts/mem_info.sh b/.config/dwm/scripts/mem_info.sh index 8ed29c1..ac8c2ad 100755 --- a/.config/dwm/scripts/mem_info.sh +++ b/.config/dwm/scripts/mem_info.sh @@ -1,6 +1,7 @@ #!/bin/bash -# Configuration variables +# Configuration variable +python_bin="/usr/bin/python3" memfile="/proc/meminfo" size="G" # Change to M for MiB @@ -12,7 +13,11 @@ memActive=$(expr ${memTotal} - ${memActive}) # Variables to calculate memTotalM=$(expr ${memTotal} / 1024 ) memActiveM=$(expr ${memActive} / 1024) -if [ -f /usr/bin/calc ] ; then +if [ -f ${python_bin} ] ; then + memPercentage=$(echo "n=${memActive}/${memTotal}*100 ; print(n)" | ${python_bin}) + memTotalG=$(echo "n=${memTotalM}/1024 ; print(n)" | ${python_bin} | tr -s " " | cut -c1-4) + memActiveG=$(echo "n=${memActiveM}/1024 ; print(n)" | ${python_bin} | tr -s " " | cut -c1-4) +elif [ -f /usr/bin/calc ] ; then memPercentage=$(calc ${memActive} / ${memTotal} \* 100) memTotalG=$(calc ${memTotalM} / 1024 | tr -s " " | cut -c1-5) memActiveG=$(calc ${memActiveM} / 1024 | tr -s " " | cut -c1-5) diff --git a/.config/waybar/scripts/mem_info.sh b/.config/waybar/scripts/mem_info.sh index 03ebb6a..2cb6092 100755 --- a/.config/waybar/scripts/mem_info.sh +++ b/.config/waybar/scripts/mem_info.sh @@ -1,6 +1,7 @@ #!/bin/bash # Configuration variables +python_bin="/usr/bin/python3" memfile="/proc/meminfo" size="G" # Change to M for MiB @@ -12,7 +13,11 @@ memActive=$(expr ${memTotal} - ${memActive}) # Variables to calculate memTotalM=$(expr ${memTotal} / 1024 ) memActiveM=$(expr ${memActive} / 1024) -if [ -f /usr/bin/calc ] ; then +if [ -f ${python_bin} ] ; then + memPercentage=$(echo "n=${memActive}/${memTotal}*100 ; print(n)" | ${python_bin}) + memTotalG=$(echo "n=${memTotalM}/1024 ; print(n)" | ${python_bin} | tr -s " " | cut -c1-4) + memActiveG=$(echo "n=${memActiveM}/1024 ; print(n)" | ${python_bin} | tr -s " " | cut -c1-4) +elif [ -f /usr/bin/calc ] ; then memPercentage=$(calc ${memActive} / ${memTotal} \* 100) memTotalG=$(calc ${memTotalM} / 1024 | tr -s " " | cut -c1-5) memActiveG=$(calc ${memActiveM} / 1024 | tr -s " " | cut -c1-5)