diff options
author | ene <ene@sils.li> | 2023-03-04 15:00:11 +0100 |
---|---|---|
committer | ene <ene@sils.li> | 2023-03-04 15:00:11 +0100 |
commit | 6e77d5a081004fb9fe0d47950bd031119c29e9c2 (patch) | |
tree | f78b0e14b4ce94330a734daa0987b2d1b4a9f911 /home-manager/config/yambar/scripts/old/meminfo | |
parent | Fix(hm/alacritty): Config (diff) | |
download | nixos-config-6e77d5a081004fb9fe0d47950bd031119c29e9c2.zip |
Feat(hm/config/yambar): Update the scripts and better paths
Diffstat (limited to 'home-manager/config/yambar/scripts/old/meminfo')
-rwxr-xr-x | home-manager/config/yambar/scripts/old/meminfo | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/home-manager/config/yambar/scripts/old/meminfo b/home-manager/config/yambar/scripts/old/meminfo new file mode 100755 index 00000000..0156e94c --- /dev/null +++ b/home-manager/config/yambar/scripts/old/meminfo @@ -0,0 +1,37 @@ +#!/bin/sh +# Checks memory usage + +# Number of seconds to retest +timer=5 + +# Main loop +while true; do + + mem_total=$(LANG=C free -b|awk '/^Mem:/{print $2}') + mem_used=$(LANG=C free -b|awk '/^Mem:/{print $3}') + swap_total=$(LANG=C free -b|awk '/^Swap:/{print $2}') + swap_used=$(LANG=C free -b|awk '/^Swap:/{print $3}') + + + memperc=$(echo "$mem_used" "$mem_total" | awk '{ div = 100 * ($1 / $2)} { printf "%.0f ", div }' | tr -d ' ' ) + swapperc=$(echo "$swap_used" "$swap_total" | awk '{ + if ( $1 == 0 || $2 == 0 ) { + print "%" + } else { + div = 100 * ($1 / $2); + printf "%.0f ", div +} +}' | tr -d ' ' ) + + +echo "memperc|string|$memperc" +if [ "$swapperc" = "%" ];then + echo "swapstate|bool|false" +else + echo "swapperc|string|$swapperc" + echo "swapstate|bool|true" +fi +echo "" +sleep "$timer" + +done |