-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpu-clock
More file actions
executable file
·34 lines (28 loc) · 855 Bytes
/
cpu-clock
File metadata and controls
executable file
·34 lines (28 loc) · 855 Bytes
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
#!/bin/bash
#set -x
labels=(🟢 🟡 🟠 🔴)
cpu_clocks=($(lscpu | grep -i "mhz" | awk '{print $NF}' | cut -d'.' -f1 | xargs echo))
cur_clock=${cpu_clocks[0]}
max_clock=${cpu_clocks[1]}
min_clock=${cpu_clocks[2]}
level1=$((($max_clock - $min_clock) / 4 * 1 + $min_clock))
level2=$((($max_clock - $min_clock) / 4 * 2 + $min_clock))
level3=$((($max_clock - $min_clock) / 4 * 3 + $min_clock))
levels=($min_clock $level1 $level2 $level3 $max_clock)
label=
for i in ${!levels[@]}; do
if [[ $i -lt 4 ]]; then
if [[ $cur_clock -gt ${levels[$i]} && $cur_clock -lt ${levels[(($i + 1))]} ]]; then
label=${labels[$i]}
fi
fi
done
ghz=$(($cur_clock / 1000))
mhz=$(($cur_clock / 100 - ghz * 10))
result=$(echo $ghz)"."$(echo $mhz)
echo "$label $result GHz"
case $BLOCK_BUTTON in
1)
cpupower-gui
;;
esac