aboutsummaryrefslogtreecommitdiff
path: root/sbc
blob: 05976427ccc2f83b5fa8e8ba08dbf4850799a7b4 (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
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh
# ==================================
# License : ./LICENSE
# Author  : sabr@ariamath.xyz
# Version : 0.0.1
# ==================================
# Honestly, brightnessctl is bloat.
# ==================================
device="$(find /sys/class/backlight/*)"
fmax="${device}/max_brightness"
fcur="${device}/brightness"
m="$(cat "${fmax}")"
c="$(cat "${fcur}")"
if [ $# -gt 1 ];
then
	case "$1" in
		"-s") printf "%d" "$(($2 * m / 100))" > "${fcur}" ;;
		"-i") printf "%d" "$((c + $2 * m / 100))" > "${fcur}" ;;
		"-d") printf "%d" "$((c - $2 * m / 100))" > "${fcur}" ;;
	esac
	notify-send "Brigthness Info" "Current Brightness: $((c * 100 / m))%"
else
	case "$1" in
		"-v")
			printf "brl v0.0.1\n"
			printf "A simple brightness control program\n"
		;;
		"-h"|"--help")
			printf "brl [options] [value]\n"
			printf " -s   set brightness %%\n"
			printf " -i   increase brightness %%\n"
			printf " -d   decrease brightness %%\n"
		;;
		*)
			printf "Current brightness: %d%% (%d)\n"\
				$((c * 100 / m)) "$c"
		;;
	esac
fi