#!/bin/bash device=$(find /sys/class/backlight/* -maxdepth 1 | head -n 1) max=$(cat "$device/max_brightness") current=$(cat "$device/brightness") step=20 case "$1" in get) echo "$current" ;; dec) if [[ "$current" -gt 0 ]]; then echo $(( current - step )) > "$device/brightness" fi ;; inc) if [[ "$current" -lt "$max" ]]; then echo $(( current + step )) > "$device/brightness" fi ;; *) echo "Unknown argument $1" >&2 exit 1 ;; esac