45 lines
1.4 KiB
Bash
Executable File
45 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Leer el valor actual del brillo
|
|
current_brightness=$(asusctl -k | grep brigh | awk '{print $5}')
|
|
|
|
# Definir los posibles valores de brillo en orden descendente
|
|
brightness_levels=("High" "Med" "Low" "Off")
|
|
|
|
# Función para obtener el índice de un valor en un array
|
|
index_of() {
|
|
local value=$1
|
|
shift
|
|
local array=("$@")
|
|
for i in "${!array[@]}"; do
|
|
if [[ "${array[$i]}" == "$value" ]]; then
|
|
echo $i
|
|
return
|
|
fi
|
|
done
|
|
echo -1
|
|
}
|
|
|
|
# Obtener el índice del valor actual de brillo
|
|
current_index=$(index_of "$current_brightness" "${brightness_levels[@]}")
|
|
|
|
# Si el valor actual no es "Off" y el índice es válido
|
|
if [[ $current_brightness != "Off" && $current_index -ge 0 ]]; then
|
|
# Calcular el índice del siguiente valor descendente
|
|
next_index=$((current_index + 1))
|
|
|
|
# Verificar si el índice es válido
|
|
if [[ $next_index -lt ${#brightness_levels[@]} ]]; then
|
|
# Obtener el siguiente valor descendente
|
|
next_brightness=${brightness_levels[$next_index]}
|
|
|
|
# Guardar el nuevo valor en el archivo
|
|
asusctl -k "$next_brightness"
|
|
echo "El brillo se ha cambiado a: $next_brightness"
|
|
else
|
|
echo "El brillo ya está en el nivel más bajo: $current_brightness"
|
|
fi
|
|
else
|
|
echo "El brillo está apagado o no se ha encontrado un valor válido. No se realizó ningún cambio."
|
|
fi
|