From 864a6b78f49402f087f29f446b9a8d33b4c67263 Mon Sep 17 00:00:00 2001 From: q3aql Date: Sat, 22 Oct 2022 18:39:01 +0200 Subject: [PATCH] Dotfiles config update (2022-10-22) --- .config/conky/scripts/mem_info.sh | 7 ++++++- .config/dwm/scripts/mem_info.sh | 9 +++++++-- .config/waybar/scripts/mem_info.sh | 7 ++++++- 3 files changed, 19 insertions(+), 4 deletions(-) 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)