Files
Arch_Hyprland_dots/.config/scripts/brightness_mode.sh
T
2026-01-17 02:04:18 +03:00

43 lines
907 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
STATE="$HOME/.config/scripts/brightness_mode"
CACHE="$HOME/.config/scripts/ddc-map.conf"
MODES=(10 35 55 80 100)
# State dizini
mkdir -p "$(dirname "$STATE")"
# Mevcut mod
MODE=$(cat "$STATE" 2>/dev/null || echo 1)
((MODE < 1 || MODE > 5)) && MODE=1
BRIGHTNESS="${MODES[$((MODE-1))]}"
# Aktif monitör
ACTIVE_MONITOR=$(hyprctl monitors -j | jq -r '.[] | select(.focused==true).name')
if [ -z "$ACTIVE_MONITOR" ]; then
notify-send "Brightness" "Aktif monitör bulunamadi"
exit 1
fi
# I2C bul
I2C=$(grep "^$ACTIVE_MONITOR=" "$CACHE" | cut -d= -f2)
if [ -z "$I2C" ]; then
notify-send "Brightness" "I2C bulunamadi: $ACTIVE_MONITOR"
exit 1
fi
# Parlaklık ayarla
ddcutil setvcp 10 "$BRIGHTNESS" --bus="$I2C"
notify-send "Brightness Mode" \
"Mode $MODE / 5 → $BRIGHTNESS% ($ACTIVE_MONITOR)"
# Sonraki moda geç
NEXT=$((MODE + 1))
((NEXT > 5)) && NEXT=1
echo "$NEXT" > "$STATE"