m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/backlight
blob: 2d5e0e2f6cc557b7596eca5649b3bfff52804abf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash

# Allows you to adjust display backlight from the command line.
# USAGE: backlight <brightness change>
# The brightness change can be positive (for brighter) or negative (for darker).
# NOTE: requires root privileges.

brightness=`cat /sys/class/backlight/intel_backlight/brightness`
delta="$1"

if [[ ! $delta =~ ^-?[0-9]+$ ]]; then
    echo "Not a number!"
    exit 1
fi

new_brightness=$((brightness + delta))


if [[ new_brightness -gt 7500 ]]; then
    new_brightness=7500
elif [[ new_brightness -lt 0 ]]; then
    new_brightness=0
fi

# echo $new_brightness
tee /sys/class/backlight/intel_backlight/brightness <<< "$new_brightness"