diff options
author | NeodarZ <neodarz@neodarz.ovh> | 2016-09-21 20:01:28 +0200 |
---|---|---|
committer | NeodarZ <neodarz@neodarz.ovh> | 2016-09-21 20:01:28 +0200 |
commit | 78db7d43845d3ea276b8028bec6d67b5a5641a1b (patch) | |
tree | 27a58084c5eac2dc9b084e9f57fd6bc762afc480 /.i3-blocks/blocks/memory | |
parent | 0cde152bf8483e894eb64c41529c5d8c6349327b (diff) | |
download | dotfiles-78db7d43845d3ea276b8028bec6d67b5a5641a1b.tar.xz dotfiles-78db7d43845d3ea276b8028bec6d67b5a5641a1b.zip |
Ajout de la conf de vim + mise à jour de la structure
Diffstat (limited to '.i3-blocks/blocks/memory')
-rwxr-xr-x | .i3-blocks/blocks/memory | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/.i3-blocks/blocks/memory b/.i3-blocks/blocks/memory deleted file mode 100755 index 866e7c3..0000000 --- a/.i3-blocks/blocks/memory +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/bash - -# First argument is source (mem/swap), second is output value -# Check /proc/meminfo for possible instances -INSTANCE="${BLOCK_INSTANCE:-mem;free}" - -SOURCE=$(echo "${INSTANCE}" | awk -F ';' '{print $1}') -DISPLAY=$(echo "${INSTANCE}" | awk -F ';' '{print $2}') - -if [[ "${SOURCE}" = "mem" ]]; then - URGENT_VALUE=90 -elif [[ "${SOURCE}" = "swap" ]]; then - URGENT_VALUE=50 -fi - -if [[ "${DISPLAY}" = "" ]]; then - DISPLAY="free" -fi - -ONE_KB=1024 -ONE_MB=$(echo "${ONE_KB}*1024" | bc -l) -ONE_GB=$(echo "${ONE_MB}*1024" | bc -l) -ONE_TB=$(echo "${ONE_GB}*1024" | bc -l) - -# Grep the value and remove KB so we can calculate with it later -#MEMINFO=$(cat /proc/meminfo | grep "${INSTANCE}" | awk -F ':' '{print $2}' | tr -d ' kB') -MEMORY_INFOS=$(cat /proc/meminfo) -SOURCE_TOTAL=$(echo "${MEMORY_INFOS}" | grep -i "${SOURCE}total" | awk -F ':' '{print $2}' | tr -d ' kB') - -if [[ "${SOURCE_TOTAL}" -le 0 ]]; then - exit -fi - -SOURCE_FREE=$(echo "${MEMORY_INFOS}" | grep -i "${SOURCE}available" | awk -F ':' '{print $2}' | tr -d ' kB') -SOURCE_USED=$(echo "scale=0; ${SOURCE_TOTAL}-${SOURCE_FREE}" | bc -l) -SOURCE_PERC=$(echo "scale=0; (${SOURCE_USED}*100)/${SOURCE_TOTAL}" | bc -l) - -if [[ "${DISPLAY}" = "free" ]]; then - MEMINFO="${SOURCE_FREE}" -elif [[ "${DISPLAY}" = "used" ]]; then - MEMINFO="${SOURCE_USED}" -elif [[ "${DISPLAY}" = "total" ]]; then - MEMINFO="${SOURCE_TOTAL}" -elif [[ "${DISPLAY}" = "perc" ]]; then - MEMINFO="${SOURCE_PERC}%" -fi - -if [[ "${DISPLAY}" != "perc" ]]; then - # Convert KB meminfo to bytes - MEMINFO=$(echo "${MEMINFO}*${ONE_KB}" | bc -l) - - if [[ "${MEMINFO}" -ge "${ONE_TB}" ]]; then - MEMINFO=$(echo "scale=3;${MEMINFO}/${ONE_TB}" | bc -l)"tb" - elif [[ "${MEMINFO}" -ge "${ONE_GB}" ]]; then - MEMINFO=$(echo "scale=2;${MEMINFO}/${ONE_GB}" | bc -l)"gb" - elif [[ "${MEMINFO}" -ge "${ONE_MB}" ]]; then - MEMINFO=$(echo "scale=1;${MEMINFO}/${ONE_MB}" | bc -l)"mb" - else - MEMINFO=$(echo "scale=0;${MEMINFO}/${ONE_KB}" | bc -l)"kb" - fi -fi - -echo "${MEMINFO}" -echo "${MEMINFO}" -echo "" - -if [[ "${SOURCE_PERC}" -gt "${URGENT_VALUE}" ]]; then - exit 33 -fi
\ No newline at end of file |