added quickshell and updated zsh
This commit is contained in:
20
home/hypr/quickshell/scripts/get_cpu.sh
Executable file
20
home/hypr/quickshell/scripts/get_cpu.sh
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
# Read /proc/stat CPU utilization
|
||||
read -r cpu u n s i io ir st g gn < /proc/stat
|
||||
total1=$((u + n + s + i + io + ir + st + g + gn))
|
||||
idle1=$((i + io))
|
||||
sleep 0.2
|
||||
read -r cpu u n s i io ir st g gn < /proc/stat
|
||||
total2=$((u + n + s + i + io + ir + st + g + gn))
|
||||
idle2=$((i + io))
|
||||
|
||||
total_diff=$((total2 - total1))
|
||||
idle_diff=$((idle2 - idle1))
|
||||
|
||||
if [ "$total_diff" -gt 0 ]; then
|
||||
cpu_usage=$(( (total_diff - idle_diff) * 100 / total_diff ))
|
||||
else
|
||||
cpu_usage=0
|
||||
fi
|
||||
|
||||
echo "$cpu_usage"
|
||||
Reference in New Issue
Block a user