diff options
author | NeodarZ <neodarz@neodarz.ovh> | 2016-11-03 23:32:29 +0100 |
---|---|---|
committer | NeodarZ <neodarz@neodarz.ovh> | 2016-11-03 23:32:29 +0100 |
commit | 85869af083741e8230cf66d1acc4a3b2da21dbd5 (patch) | |
tree | f84efd1622d327039e0c0876a39b948469c42388 /i3/blocks/memory | |
parent | 146b416466cda8fdb6151bf73f99fa65a483fc09 (diff) | |
download | dotfiles-85869af083741e8230cf66d1acc4a3b2da21dbd5.tar.xz dotfiles-85869af083741e8230cf66d1acc4a3b2da21dbd5.zip |
Add the new i3 configuration
Diffstat (limited to 'i3/blocks/memory')
-rwxr-xr-x | i3/blocks/memory | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/i3/blocks/memory b/i3/blocks/memory deleted file mode 100755 index 866e7c3..0000000 --- a/i3/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 |