summaryrefslogtreecommitdiff
path: root/.local/bin/statusbar/cpuinfo
blob: 05ab3deb76564f147f78f2bb1cc133a2c29bab28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env bash
set -e

ARG=${1:-$BLOCK_BUTTON}

case $ARG in
	1) notify-send --urgency=low   \
	   "Process status"            \
	   "$(ps k-c -eo pid,pcpu,comm | head -10 \
	      | sed -E 's/ +/ /g;s/^ +//' \
	      | column -tl 3 -R 1,2 -s ' ')"
	;;
	3) notify-send --urgency=low   \
	   "Process status"            \
	   "$(ps k-vsz -eo pid,pcpu,vsz,comm \
	      | head -10  \
	      | awk 'NR>1 {$3 = int($3/1024)"M";}{print;}' \
	      | sed -E 's/ +/ /g;s/^ +//' \
	      | column -tl 4 -R 1,2,3 -s ' ')"
	;;
esac

# Thermals
# "Never cat something into awk", yeah, but it won't function properly if it
# encounters a missing `/temp`-file.
TEMP="$(cat /sys/class/thermal/thermal_zone*/temp 2>/dev/null)"
TEMP="$(echo "${TEMP}" | awk '{s+=$1}END{printf "%.1f", s / (1000*NR)}' )"
# Color red if temp > 45
TEMP=`(( $(echo "$TEMP > 45" | bc -l) )) && echo -en "\x0c${TEMP}\x0b" || echo -en "$TEMP"`

# Load
LOAD=$(sed -Ee 's/^([0-9]+\.[0-9]+) .*/\1/g' /proc/loadavg | tr -d '\n')


echo -en "[${LOAD} \x0f\x0b ${TEMP}°]"