From 0c2387aa7c4241cf018d18d560e9ff68fc84d9fe Mon Sep 17 00:00:00 2001 From: stuffbymax <96355058+stuffbymax@users.noreply.github.com> Date: Sun, 30 Jun 2024 01:57:30 +0100 Subject: [PATCH 1/4] Update namaskar.sh --- namaskar.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/namaskar.sh b/namaskar.sh index ed44734..e651168 100644 --- a/namaskar.sh +++ b/namaskar.sh @@ -1,4 +1,27 @@ #!/bin/bash + + +# Function to calculate percentage +get_percentage() { + used=$1 + total=$2 + awk -v used="$used" -v total="$total" 'BEGIN { printf("%.2f%%", (used / total) * 100) }' +} + +# Get memory and swap usage details +memory_usage=$(free -h --si | awk '/^Mem/ {print $3 " / " $2}') +swap_usage=$(free -h --si | awk '/^Swap/ {print $3 " / " $2}') + +# Calculate percentage for memory +memory_used=$(free --si | awk '/^Mem/ {print $3}') +memory_total=$(free --si | awk '/^Mem/ {print $2}') +memory_percentage=$(get_percentage "$memory_used" "$memory_total") + +# Calculate percentage for swap +swap_used=$(free --si | awk '/^Swap/ {print $3}') +swap_total=$(free --si | awk '/^Swap/ {print $2}') +swap_percentage=$(get_percentage "$swap_used" "$swap_total") + host=$(uname -n) user=$(whoami) shell=$(echo $SHELL) @@ -6,6 +29,8 @@ kernel="$(uname -r)" shell="$(basename "${SHELL}")" os="$(uname -s)" uptime="$(uptime -p)" + + echo"" c1=$(echo -e "\e[42m \e[0m") c2=$(echo -e "\e[41m \e[0m") c3=$(echo -e "\e[43m \e[0m") @@ -19,6 +44,8 @@ ${c2} │ ┌─┼─┐ host : ${host} ${c3} │ │ │ │ user : ${user} ${c4} └─┼─┘ │ kernel : ${kernel} ${c5} └───┘ shell : ${shell} +${c5} └───┘ ram : $($memory_percentage) ($memory_usage +${c5} └───┘ swap : $($swap_percentage) ($swap_usage)  ${uptime} From f3a55de70310b9a1807c5b042a9a52ae849d02e9 Mon Sep 17 00:00:00 2001 From: stuffbymax <96355058+stuffbymax@users.noreply.github.com> Date: Sun, 30 Jun 2024 21:04:51 +0100 Subject: [PATCH 2/4] Update namaskar.sh --- namaskar.sh | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/namaskar.sh b/namaskar.sh index e651168..ac8d2fb 100644 --- a/namaskar.sh +++ b/namaskar.sh @@ -1,6 +1,5 @@ #!/bin/bash - # Function to calculate percentage get_percentage() { used=$1 @@ -24,13 +23,12 @@ swap_percentage=$(get_percentage "$swap_used" "$swap_total") host=$(uname -n) user=$(whoami) -shell=$(echo $SHELL) -kernel="$(uname -r)" -shell="$(basename "${SHELL}")" -os="$(uname -s)" -uptime="$(uptime -p)" +shell=$(basename "$SHELL") +kernel=$(uname -r) +os=$(uname -s) +uptime=$(uptime -p) - echo"" +echo "" c1=$(echo -e "\e[42m \e[0m") c2=$(echo -e "\e[41m \e[0m") c3=$(echo -e "\e[43m \e[0m") @@ -44,8 +42,8 @@ ${c2} │ ┌─┼─┐ host : ${host} ${c3} │ │ │ │ user : ${user} ${c4} └─┼─┘ │ kernel : ${kernel} ${c5} └───┘ shell : ${shell} -${c5} └───┘ ram : $($memory_percentage) ($memory_usage -${c5} └───┘ swap : $($swap_percentage) ($swap_usage) +${c5} └───┘ ram : ${memory_percentage} (${memory_usage}) +${c5} └───┘ swap : ${swap_percentage} (${swap_usage})  ${uptime} From fa5c13e496bf2a0bb61675fa1d99074a2f1b7d44 Mon Sep 17 00:00:00 2001 From: stuffbymax <96355058+stuffbymax@users.noreply.github.com> Date: Sat, 6 Jul 2024 10:47:50 +0100 Subject: [PATCH 3/4] Update namaskar.sh --- namaskar.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/namaskar.sh b/namaskar.sh index ac8d2fb..99d9f61 100644 --- a/namaskar.sh +++ b/namaskar.sh @@ -34,6 +34,7 @@ c2=$(echo -e "\e[41m \e[0m") c3=$(echo -e "\e[43m \e[0m") c4=$(echo -e "\e[44m \e[0m") c5=$(echo -e "\e[45m \e[0m") +c6=$(echo -e "\e[46m \e[0m") cat < Date: Sat, 6 Jul 2024 10:53:56 +0100 Subject: [PATCH 4/4] Update namaskar.sh --- namaskar.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/namaskar.sh b/namaskar.sh index 99d9f61..f365e83 100644 --- a/namaskar.sh +++ b/namaskar.sh @@ -45,7 +45,7 @@ ${c4} └─┼─┘ │ kernel : ${kernel} ${c5} └───┘ shell : ${shell} ${c5} └───┘ ram : ${memory_percentage} (${memory_usage}) ${c5} └───┘ swap : ${swap_percentage} (${swap_usage}) -${c6} └───┘ uptime : ${uptime} +${c6} └───┘ uptime : ${uptime} EOF