31 lines
1.2 KiB
Bash
Executable File
31 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Obtener uso de la GPU con nvidia-smi
|
|
usage=$(nvidia-smi --query-gpu=utilization.gpu --format=csv,noheader,nounits | head -n 1)
|
|
temp=$(nvidia-smi --query-gpu=temperature.gpu --format=csv,noheader,nounits | head -n 1)
|
|
|
|
temp_formated=$(printf "%02d\n" $temp)
|
|
usage_formated=$(printf "%02d\n" $usage)
|
|
|
|
progress_gpu=$(sh ~/.config/waybar/scripts/status_bar.sh $usage)
|
|
|
|
# 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} 
 "" GPU ${temp_formated}°C / ${usage_formated}% $progress_gpu"
|