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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
[shapeshifter@tachychineta shapeshifter]$ cat /usr/bin/asus-screen-brightness 
#!/bin/bash

path="/sys/class/backlight/intel_backlight"

        # max should be 4296
        max=$(cat ${path}/max_brightness)
        
        step=$(($max/10))
        # for a value smaller than treshold, the steps are smaller for a more accurate setting at low in          tensity
        treshold=$((2*$step))
        previous=$(cat ${path}/brightness)
        
        function commit {
        	if [[ $1 = [0-9]* ]]
        	then 
        		if [[ $1 -gt $max ]]
        		then 
        			next=$max
        		elif [[ $1 -lt 0 ]]
        		then 
        			next=0
        		else 
        			next=$1
        		fi
        		echo $next >> ${path}/brightness
        		exit 0
        	else 
        		exit 1
        	fi
        }
        
        case "$1" in
         up)
        	if [[ $previous -le $treshold ]]
        	then 
        	    step=$(($step/4))
        	fi
        	commit $(($previous + $step))
           ;;
         down)
        	if [[ $previous -le $treshold ]]
        	then 
        	    step=$(($step/4))
        	fi
        	commit $(($previous - $step))
           ;;
         max)
        	 commit $max
           ;;
         off)
        	 commit 0
           ;;
         show)
        	 echo $previous
           ;;
         night)
        	 commit $(($max/4)) 
         	 ;;
         allowusers)
        	 # Allow members of users group to change brightness
        	 sudo chgrp users ${path}/brightness
        	 sudo chmod g+w ${path}/brightness
           ;;
         disallowusers)
        	 # Disallow members of users group to change brightness
        	 sudo chgrp root ${path}/brightness
        	 sudo chmod g-w ${path}/brightness
           ;;
         *)
        	 commit	$1
        esac
        
        exit 0		

[shapeshifter@tachychineta shapeshifter]$