#!/bin/sh

export BRIGHTNESS=`brightnessctl g`
if [ $BRIGHTNESS == 0 ]; then
    killall gammastep &> /dev/null

    export BRIGHTNESS=`cat /tmp/brightness 2> /dev/null || echo 1` 
    if [ `echo "$BRIGHTNESS < 1.0" | bc -l` == 1 ]; then
        export BRIGHTNESS=`echo "$BRIGHTNESS + 0.1" | bc`
        echo $BRIGHTNESS > /tmp/brightness
        gammastep -O 6500 -b $BRIGHTNESS:0.1 &
    else
        brightnessctl set 5%
    fi
else
    brightnessctl set +5%
fi

