diff --git a/i3blocks/battery_status.sh b/i3blocks/battery_status.sh index f126a62..7510289 100755 --- a/i3blocks/battery_status.sh +++ b/i3blocks/battery_status.sh @@ -4,7 +4,7 @@ acpi -b | awk -F', ' ' /Battery/ { split($2, percent, "%") split($3, time, " ") - printf " Battery: %d%%", percent[1] + printf " %d%%", percent[1] if (time[1] != "") printf ", %s", time[1] if ($1 ~ /Charging/) printf ", Charging" printf "\n" diff --git a/i3blocks/cpu_gpu_monitor.sh b/i3blocks/cpu_gpu_monitor.sh index fd743d2..b543e08 100755 --- a/i3blocks/cpu_gpu_monitor.sh +++ b/i3blocks/cpu_gpu_monitor.sh @@ -2,32 +2,50 @@ # CPU Temperature cpu_temp=$(sensors | awk '/^Tctl:/ {print $2}' | tr -d '+°C') +if [ -z "$cpu_temp" ]; then + cpu_temp="N/A" +fi # CPU Load (1-minute average) cpu_load=$(awk '{print $1}' /proc/loadavg) +if [ -z "$cpu_load" ]; then + cpu_load="N/A" +fi # GPU Temperature gpu_temp=$(nvidia-smi --query-gpu=temperature.gpu --format=csv,noheader,nounits 2>/dev/null) +if [ -z "$gpu_temp" ]; then + gpu_temp="N/A" +fi # GPU Load gpu_load=$(nvidia-smi --query-gpu=utilization.gpu --format=csv,noheader,nounits 2>/dev/null) +if [ -z "$gpu_load" ]; then + gpu_load="N/A" +fi # Colors for CPU Load -if (( $(echo "$cpu_load < 1.0" | bc -l) )); then - cpu_color="#50FA7B" # Green -elif (( $(echo "$cpu_load < 2.0" | bc -l) )); then - cpu_color="#F1FA8C" # Yellow -else - cpu_color="#FF5555" # Red +cpu_color="#FFFFFF" # Default color +if [[ "$cpu_load" != "N/A" ]]; then + if (( $(echo "$cpu_load < 1.0" | bc -l) )); then + cpu_color="#50FA7B" # Green + elif (( $(echo "$cpu_load < 2.0" | bc -l) )); then + cpu_color="#F1FA8C" # Yellow + else + cpu_color="#FF5555" # Red + fi fi # Colors for GPU Load -if (( $(echo "$gpu_load < 50.0" | bc -l) )); then - gpu_color="#50FA7B" # Green -elif (( $(echo "$gpu_load < 75.0" | bc -l) )); then - gpu_color="#F1FA8C" # Yellow -else - gpu_color="#FF5555" # Red +gpu_color="#FFFFFF" # Default color +if [[ "$gpu_load" != "N/A" ]]; then + if (( $(echo "$gpu_load < 50.0" | bc -l) )); then + gpu_color="#50FA7B" # Green + elif (( $(echo "$gpu_load < 75.0" | bc -l) )); then + gpu_color="#F1FA8C" # Yellow + else + gpu_color="#FF5555" # Red + fi fi # Output diff --git a/install.sh b/install.sh index d179ef3..7e918f6 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,5 @@ #!/bin/sh -sudo pacman -S --needed ttf-dejavu noto-fonts ttf-font-awesome +sudo pacman -S --needed ttf-dejavu noto-fonts ttf-font-awesome bc cp -r i3blocks ~/.config/ cp -r i3 ~/.config/ i3-msg reload