blob: a377c600ed47ab48fd9c582bf43dc410bd4589a5 (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#!/bin/zsh
date_time() {
datetime=$(date +"%d %b(%A) %H:%M")
echo $datetime
}
cpu_load() {
read cpu a b c previdle rest < /proc/stat
prevtotal=$((a+b+c+previdle))
sleep 0.5
read cpu a b c idle rest < /proc/stat
total=$((a+b+c+idle))
cpu=$((100*( (total-prevtotal) - (idle-previdle) ) / (total-prevtotal) ))
echo -e "CPU: $cpu%"
}
cpu_temp() {
CEL=$'\xc2\xb0C'
temp=$( cat /sys/devices/virtual/thermal/thermal_zone0/temp )
temp=`expr $temp / 1000`
echo "TEMP: " $temp$CEL
}
root_usage() {
root=$(df -h / | awk 'NR==2 {print $4 "/" $2}')
echo "ROOT: "$root
}
home_usage() {
home=$(df -h /home | awk 'NR==2 {print $4 "/" $2}')
echo "HOME: "$home
}
mem_usage() {
mem=$(free -m | grep Mem: | awk '{print$3 / $2 * 100}')
printf "MEM: %.0f %%" $mem
}
while :; do
echo $(date_time) > /home/zt/.cache/lemon/clock
echo $(cpu_load) > /home/zt/.cache/lemon/cpu_load
echo $(cpu_temp) > /home/zt/.cache/lemon/cpu_temp
echo $(root_usage) > /home/zt/.cache/lemon/disk_root
echo $(home_usage) > /home/zt/.cache/lemon/disk_home
echo $(mem_usage) > /home/zt/.cache/lemon/mem
sleep 3
done
|