aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/sysmon
blob: d04b5a31e8e80ca5d3b8b47689146e08b2f08470 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh

cpu_usage() {
	first=$(grep 'cpu ' /proc/stat)
	sleep 0.05
	second=$(grep 'cpu ' /proc/stat)
	usage=$(printf "%s\n%s\n" "$first" "$second" | awk '{u=$2+$4; t=$2+$4+$5; if (NR==1){u1=u; t1=t;} else print ($2+$4-u1) * 100 / (t-t1); }' | sed -e 's/\..*//g')

	printf "󰇅 "
	bar "$usage"
}

ram_usage() {
	printf "  "
	usage=$(free | awk '/Mem/ { print $3 / $2 * 100 }' | sed -e 's/\..*//g')
	bar "$usage"
}


ram_usage
cpu_usage