[AGS] Bar: BT, Audio, SysInfo, Brightness
This commit is contained in:
		
							
								
								
									
										20
									
								
								scripts/cpu-utilization
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										20
									
								
								scripts/cpu-utilization
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,20 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| # Get first snapshot | ||||
| read cpu user nice system idle iowait irq softirq steal guest < /proc/stat | ||||
| total1=$((user+nice+system+idle+iowait+irq+softirq+steal)) | ||||
| idle1=$idle | ||||
|  | ||||
| sleep 0.5 | ||||
|  | ||||
| # Get second snapshot | ||||
| read cpu user nice system idle iowait irq softirq steal guest < /proc/stat | ||||
| total2=$((user+nice+system+idle+iowait+irq+softirq+steal)) | ||||
| idle2=$idle | ||||
|  | ||||
| # Calculate usage | ||||
| total_diff=$((total2 - total1)) | ||||
| idle_diff=$((idle2 - idle1)) | ||||
| cpu_usage=$((100 * (total_diff - idle_diff) / total_diff)) | ||||
|  | ||||
| echo "$cpu_usage" | ||||
		Reference in New Issue
	
	Block a user