aboutsummaryrefslogtreecommitdiff
path: root/.i3-blocks/blocks/load
blob: 448876fa37d8e7af5de6981033467c27132e9ba2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash

INSTANCE="${BLOCK_INSTANCE:-1}"

URGENT_VALUE=90

LOAD=$(cat /proc/loadavg | awk -F ' ' '{print $'"${INSTANCE}"'}')
if [[ "${LOAD}" != "" ]]; then
  LOAD_PERC=$(echo "scale=0; ${LOAD} * 100" | bc -l)
  LOAD_PERC=${LOAD_PERC%.*}

  echo "${LOAD}"
  echo "${LOAD}"
  echo ""

  if [[ "${LOAD_PERC}" -ge "${URGENT_VALUE}" ]]; then
    exit 33
  fi
fi