#!/usr/bin/env bash STATE_FILE="/tmp/fancycle_state" HWMON_PATH="/sys/class/hwmon/hwmon7" # Ajusta según tu caso # Si no existe el archivo de estado, inícialo en 1 (fan1) if [[ ! -f "$STATE_FILE" ]]; then echo 1 > "$STATE_FILE" fi # Si el script es invocado con el argumento "next", incrementa el estado if [[ "$1" == "next" ]]; then current_state=$(cat "$STATE_FILE") # Suponiendo que tienes 3 ventiladores y quieres ciclar 1->2->3->1->... next_state=$(( (current_state % 3) + 1 )) echo "$next_state" > "$STATE_FILE" fi # Lee el estado actual state=$(cat "$STATE_FILE") # Lee la info real de tus ventiladores # Lee la info real de tus ventiladores fan1_label=$(cat "$HWMON_PATH/fan1_label" 2>/dev/null | sed 's/_fan//I' | tr '[:lower:]' '[:upper:]') fan1_speed=$(cat "$HWMON_PATH/fan1_input" 2>/dev/null) fan2_label=$(cat "$HWMON_PATH/fan2_label" 2>/dev/null | sed 's/_fan//I' | tr '[:lower:]' '[:upper:]') fan2_speed=$(cat "$HWMON_PATH/fan2_input" 2>/dev/null) # Prepara el tooltip con TODOS los ventiladores tooltip="${fan1_label}: ${fan1_speed}  ${fan2_label}: ${fan2_speed} " # Según el "estado", decide cuál ventilador se muestra en "text" case "$state" in 1) text="${fan1_label}: ${fan1_speed} " ;; 2) text="${fan2_label}: ${fan2_speed} " ;; esac # Usa jq para generar JSON jq -c -n \ --arg text "$text" \ --arg tooltip "$tooltip" \ '{ "text": $text, "tooltip": $tooltip }'