Dotfiles config update (2022-10-07)

This commit is contained in:
q3aql 2022-10-07 00:24:37 +02:00
parent 80d9d065b3
commit 322c188acc
6 changed files with 127 additions and 5 deletions

View File

@ -1,4 +1,40 @@
#!/bin/bash #!/bin/bash
mem_info=$(free -h | awk '/Mem:/ { printf(" %5s/%s \n", $3, $2) }') # Configuration variables
echo ${mem_info} memfile="/proc/meminfo"
size="G" # Change to M for MiB
# Variables
memTotal=$(cat ${memfile} | grep -i "memtotal:" | head -1 | tr -s " " | cut -d " " -f 2)
memActive=$(cat ${memfile} | grep -i "memavailable:" | head -1 | tr -s " " | cut -d " " -f 2)
memActive=$(expr ${memTotal} - ${memActive})
# Variables to calculate
memTotalM=$(expr ${memTotal} / 1024 )
memActiveM=$(expr ${memActive} / 1024)
if [ -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)
else
memPercentage=$(expr ${memActive} / ${memTotal} \* 100)
memTotalG=$(expr ${memTotalM} / 1024 | tr -s " " | cut -c1-5)
memActiveG=$(expr ${memActiveM} / 1024 | tr -s " " | cut -c1-5)
fi
# Variables to show
showMemPercentage=$(echo ${memPercentage} | cut -d "~" -f 2 | cut -d "." -f 1)
if [ "${size}" == "G" ] ; then
showMemTotal="${memTotalG}Gi"
showMemActive="${memActiveG}Gi"
elif [ "${size}" == "M" ] ; then
showMemTotal="${memTotalM}Mi"
showMemActive="${memActiveM}Mi"
else
showMemTotal="${memTotalG}Gi"
showMemActive="${memActiveG}Gi"
fi
memshowactive=$(echo ${showMemActive})
memshowtotal=$(echo ${showMemTotal})
echo ${memshowactive}/${memshowtotal}

View File

@ -0,0 +1,4 @@
#!/bin/bash
mem_info=$(free -h | awk '/Mem:/ { printf(" %5s/%s \n", $3, $2) }')
echo ${mem_info}

View File

@ -1,6 +1,42 @@
#!/bin/bash #!/bin/bash
mem_info=$(free -h | awk '/Mem:/ { printf(" %5s/%s \n", $3, $2) }') # Configuration variables
memfile="/proc/meminfo"
size="G" # Change to M for MiB
# Variables
memTotal=$(cat ${memfile} | grep -i "memtotal:" | head -1 | tr -s " " | cut -d " " -f 2)
memActive=$(cat ${memfile} | grep -i "memavailable:" | head -1 | tr -s " " | cut -d " " -f 2)
memActive=$(expr ${memTotal} - ${memActive})
# Variables to calculate
memTotalM=$(expr ${memTotal} / 1024 )
memActiveM=$(expr ${memActive} / 1024)
if [ -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)
else
memPercentage=$(expr ${memActive} / ${memTotal} \* 100)
memTotalG=$(expr ${memTotalM} / 1024 | tr -s " " | cut -c1-5)
memActiveG=$(expr ${memActiveM} / 1024 | tr -s " " | cut -c1-5)
fi
# Variables to show
showMemPercentage=$(echo ${memPercentage} | cut -d "~" -f 2 | cut -d "." -f 1)
if [ "${size}" == "G" ] ; then
showMemTotal="${memTotalG}Gi"
showMemActive="${memActiveG}Gi"
elif [ "${size}" == "M" ] ; then
showMemTotal="${memTotalM}Mi"
showMemActive="${memActiveM}Mi"
else
showMemTotal="${memTotalG}Gi"
showMemActive="${memActiveG}Gi"
fi
echo -n " " echo -n " "
echo -n ${mem_info} memshowactive=$(echo ${showMemActive})
memshowtotal=$(echo ${showMemTotal})
echo -n ${memshowactive}/${memshowtotal}
echo " " echo " "

View File

@ -0,0 +1,6 @@
#!/bin/bash
mem_info=$(free -h | awk '/Mem:/ { printf(" %5s/%s \n", $3, $2) }')
echo -n " "
echo -n ${mem_info}
echo " "

View File

@ -1,3 +1,40 @@
#!/bin/bash #!/bin/bash
free -h | awk '/Mem:/ { printf(" %5s / %s \n", $3, $2) }' # Configuration variables
memfile="/proc/meminfo"
size="G" # Change to M for MiB
# Variables
memTotal=$(cat ${memfile} | grep -i "memtotal:" | head -1 | tr -s " " | cut -d " " -f 2)
memActive=$(cat ${memfile} | grep -i "memavailable:" | head -1 | tr -s " " | cut -d " " -f 2)
memActive=$(expr ${memTotal} - ${memActive})
# Variables to calculate
memTotalM=$(expr ${memTotal} / 1024 )
memActiveM=$(expr ${memActive} / 1024)
if [ -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)
else
memPercentage=$(expr ${memActive} / ${memTotal} \* 100)
memTotalG=$(expr ${memTotalM} / 1024 | tr -s " " | cut -c1-5)
memActiveG=$(expr ${memActiveM} / 1024 | tr -s " " | cut -c1-5)
fi
# Variables to show
showMemPercentage=$(echo ${memPercentage} | cut -d "~" -f 2 | cut -d "." -f 1)
if [ "${size}" == "G" ] ; then
showMemTotal="${memTotalG}Gi"
showMemActive="${memActiveG}Gi"
elif [ "${size}" == "M" ] ; then
showMemTotal="${memTotalM}Mi"
showMemActive="${memActiveM}Mi"
else
showMemTotal="${memTotalG}Gi"
showMemActive="${memActiveG}Gi"
fi
memshowactive=$(echo ${showMemActive})
memshowtotal=$(echo ${showMemTotal})
echo " ${memshowactive} / ${memshowtotal}"

View File

@ -0,0 +1,3 @@
#!/bin/bash
free -h | awk '/Mem:/ { printf(" %5s / %s \n", $3, $2) }'