File: olpc-brightness

package info (click to toggle)
olpc-kbdshim 12-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 208 kB
  • ctags: 178
  • sloc: ansic: 1,868; sh: 132; makefile: 73
file content (50 lines) | stat: -rwxr-xr-x 903 bytes parent folder | download
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
#!/bin/sh

# adjust brightness of the OLPC XO backlight

usage()
{
    	echo "usage: ${0##*/} [up|down|max|min|<0-15>]"
	exit 1;
}

LEVEL=/sys/class/backlight/dcon-bl/brightness
MONOMODE=/sys/devices/platform/dcon/output

read curbright < $LEVEL

case $1 in
    "")	# no argument, just report current value
	    echo $curbright
	    exit
	    ;;
    max|high)
	    newbright=15
	    ;;
    min|low)
	    newbright=0
	    ;;
    up)
	    newbright=$(($curbright + 1))
	    newbright=$(( ( $newbright > 15 ) ? 15 : $newbright ))
	    ;;
    down)
	    newbright=$(($curbright - 1))
	    newbright=$(( ( $newbright < 0 ) ? 0 : $newbright ))
	    ;;

    [0-9]|1[0-5])
	    newbright=$1
	    ;;
    *)
	    usage
	    ;;
esac

monochrome=$(( newbright == 0 ))

# POWEREVENTS=/var/run/powerevents
# echo "brightness $newbright $monochrome" > $POWEREVENTS

echo $newbright >$LEVEL
echo $monochrome >$MONOMODE