i3 backlight

Krystian znów będzie się śmiał z mojego managera okien i braku sprzętowej regulacji jasności w laptoku…

#! /bin/bash

#i3 intel backlight - michal.lasisz@gmail.com
#bindsym XF86MonBrightnessUp exec --no-startup-id beklajt plus #increase brightness
#bindsym XF86MonBrightnessDown exec --no-startup-id beklajt minus #decrease brightness

DIR=/sys/class/backlight/intel_backlight
what=$1
STEP=1000

MAX=$(head -n 1 "$DIR/max_brightness")
CURRENT=$(head -n 1 "$DIR/brightness")
MIN=100

if [ "$what" == "plus" ]; then

    NEW=$(($STEP+$CURRENT))

    if [ "$NEW" -gt "$MAX" ]; then
        RESOOLT=$MAX
    else
        RESOOLT=$NEW
    fi
    if [ "$CURRENT" -ne "$RESOOLT" ]; then
        tee "$DIR/brightness" << /dev/null
        notify-send $RESOOLT -t 1000
        exit
    fi
    if [ "$CURRENT" -eq "$RESOOLT" ]; then
        notify-send 'MAX brightness' -t 1000
        exit
    fi
fi

if [ "$what" == "minus" ]; then

    NEW=$(($CURRENT-$STEP))

    if [ "$NEW" -lt "$MIN" ]; then
        RESOOLT=$MIN
    else
        RESOOLT=$NEW
    fi
    if [ "$CURRENT" -ne "$RESOOLT" ]; then
        tee "$DIR/brightness" << /dev/null
        notify-send $RESOOLT -t 1000
        exit
    fi
    if [ "$CURRENT" -eq "$RESOOLT" ]; then
        notify-send 'MIN brightness' -t 1000
        exit
    fi
fi

Dodaj komentarz