#!/bin/bash
STATE_FILE="$HOME/.cache/brightness_state"
TEMP_FILE="$HOME/.cache/bluelight_state"

CURRENT=$(cat "$TEMP_FILE" 2>/dev/null || echo "6500")
BRIGHTNESS=$(cat "$STATE_FILE" 2>/dev/null || echo "1.0")

if [ "$CURRENT" = "6500" ]; then
  NEW=3400
  MSG="ON"
else
  NEW=6500
  MSG="OFF"
fi

pkill -9 gammastep
gammastep -O $NEW -b "$BRIGHTNESS" &>/dev/null &

echo "$NEW" >"$TEMP_FILE"
notify-send "Blue Light" "$MSG" -t 1000
