aboutsummaryrefslogtreecommitdiff
path: root/.i3-blocks/blocks/bandwidth
diff options
context:
space:
mode:
authorNeodarZ <neodarz@neodarz.ovh>2016-09-21 20:06:02 +0200
committerNeodarZ <neodarz@neodarz.ovh>2016-09-21 20:06:02 +0200
commitf0b7ce9877b22014022ff1a3035a2f3be262b337 (patch)
treea37046f05a746886bb336ec42e8997632cd0aaf9 /.i3-blocks/blocks/bandwidth
parentafb981f0fe8fa0de77f7451d6907f5094c38f1b5 (diff)
parent78db7d43845d3ea276b8028bec6d67b5a5641a1b (diff)
downloaddotfiles-f0b7ce9877b22014022ff1a3035a2f3be262b337.tar.xz
dotfiles-f0b7ce9877b22014022ff1a3035a2f3be262b337.zip
Ajout de la police awesome
Diffstat (limited to '.i3-blocks/blocks/bandwidth')
-rwxr-xr-x.i3-blocks/blocks/bandwidth96
1 files changed, 0 insertions, 96 deletions
diff --git a/.i3-blocks/blocks/bandwidth b/.i3-blocks/blocks/bandwidth
deleted file mode 100755
index f0b18cf..0000000
--- a/.i3-blocks/blocks/bandwidth
+++ /dev/null
@@ -1,96 +0,0 @@
-#!/bin/bash
-# Source: http://www.onlamp.com/pub/a/linux/2000/11/16/LinuxAdmin.html
-
-INSTANCE="${BLOCK_INSTANCE}"
-
-if [[ "${INSTANCE}" = "" ]]; then
- INSTANCE="wlp3s0;both"
-fi
-
-DISPLAY=$(echo "${INSTANCE}" | awk -F ';' '{print $2}')
-INSTANCE=$(echo "${INSTANCE}" | awk -F ';' '{print $1}')
-
-if [[ "${DISPLAY}" = "" ]]; then
- DISPLAY="both"
-fi
-
-ONE_KB=1024
-ONE_MB=$(echo "${ONE_KB}*1024" | bc -l)
-TEN_MB=$(echo "${ONE_MB}*10" | bc -l)
-OHD_MB=$(echo "${TEN_MB}*10" | bc -l)
-
-URGENT_VALUE="${ONE_MB}"
-
-PREV_IN=0
-PREV_OUT=0
-
-PREV_FILE="/tmp/.bandwidth"
-
-if [[ -f "${PREV_FILE}" ]]; then
- PREV_CONT=$(cat "${PREV_FILE}")
- PREV_IN=$(echo "${PREV_CONT}" | head -n 1)
- PREV_OUT=$(echo "${PREV_CONT}" | tail -n 1)
-fi
-
-BANDWIDTH=$(grep "${INSTANCE}" /proc/net/dev | awk -F: '{print $2}' | awk '{print $1" "$9}')
-
-if [[ "${BANDWIDTH}" = "" ]]; then
- exit
-fi
-
-BYTES_IN=$(echo "${BANDWIDTH}" | awk -F ' ' '{print $1}')
-BYTES_OUT=$(echo "${BANDWIDTH}" | awk -F ' ' '{print $2}')
-
-function FormatNumber() {
- if [[ "${1}" -ge "${OHD_MB}" ]]; then
- echo $(echo "scale=0;${1}/${ONE_MB}" | bc -l)"mb"
- elif [[ "${1}" -ge "${TEN_MB}" ]]; then
- echo $(echo "scale=1;${1}/${ONE_MB}" | bc -l)"mb"
- elif [[ "${1}" -ge "${ONE_MB}" ]]; then
- echo $(echo "scale=2;${1}/${ONE_MB}" | bc -l)"mb"
- elif [[ "${1}" -ge "${ONE_KB}" ]]; then
- echo $(echo "scale=0;${1}/${ONE_KB}" | bc -l)"kb"
- else
- echo "${1}""b"
- fi
-}
-
-if [[ "${PREV_IN}" != "" ]] && [[ "${PREV_OUT}" != "" ]]; then
- # Calculate the CPU usage since we last checked.
- DIFF_IN=$(echo "scale=0;${BYTES_IN} - ${PREV_IN}" | bc -l)
- DIFF_OUT=$(echo "scale=0;${BYTES_OUT} - ${PREV_OUT}" | bc -l)
- DIFF_TOTAL=0
-
- USAGE_IN=$(FormatNumber "${DIFF_IN}")
- USAGE_OUT=$(FormatNumber "${DIFF_OUT}")
-
- if [[ "${DISPLAY}" = "both" ]]; then
- echo "${USAGE_IN} : ${USAGE_OUT}"
- echo "${USAGE_IN} : ${USAGE_OUT}"
- echo ""
- DIFF_TOTAL=$((DIFF_TOTAL+DIFF_IN))
- DIFF_TOTAL=$((DIFF_TOTAL+DIFF_OUT))
- elif [[ "${DISPLAY}" = "in" ]]; then
- echo "${USAGE_IN}"
- echo "${USAGE_IN}"
- echo ""
- DIFF_TOTAL=$((DIFF_TOTAL+DIFF_IN))
- elif [[ "${DISPLAY}" = "out" ]]; then
- echo "${USAGE_OUT}"
- echo "${USAGE_OUT}"
- echo ""
- DIFF_TOTAL=$((DIFF_TOTAL+DIFF_OUT))
- fi
-else
- echo "?"
- echo "?"
- echo ""
-fi
-
-# Remember the total and idle CPU times for the next check.
-echo "${BYTES_IN}" > "${PREV_FILE}"
-echo "${BYTES_OUT}" >> "${PREV_FILE}"
-
-if [[ "${DIFF_TOTAL}" -ge "${URGENT_VALUE}" ]]; then
- exit 33
-fi \ No newline at end of file