22 lines
745 B
Bash
Executable File
22 lines
745 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Obtener temperatura desde sysfs
|
|
temp_raw=$(cat /sys/class/hwmon/hwmon2/temp1_input)
|
|
temp_c=$((temp_raw / 1000))
|
|
|
|
# Obtener uso de CPU
|
|
usage=$(grep 'cpu ' /proc/stat | awk '{u=$2+$4; t=$2+$4+$5; print u, t}')
|
|
sleep 0.5
|
|
usage2=$(grep 'cpu ' /proc/stat | awk '{u=$2+$4; t=$2+$4+$5; print u, t}')
|
|
u1=$(echo $usage | awk '{print $1}')
|
|
t1=$(echo $usage | awk '{print $2}')
|
|
u2=$(echo $usage2 | awk '{print $1}')
|
|
t2=$(echo $usage2 | awk '{print $2}')
|
|
cpu_usage=$((100 * (u2 - u1) / (t2 - t1)))
|
|
cpu_usage_formated=$(printf "%02d\n" $cpu_usage)
|
|
temp_c_formated=$(printf "%02d\n" $temp_c)
|
|
progress=$(sh ~/.config/waybar/scripts/status_bar.sh $cpu_usage)
|
|
|
|
# Imprimir formato
|
|
echo " CPU ${temp_c}°C / ${cpu_usage_formated}% ${progress}"
|