/usr/bin/olpc-brightness is in olpc-kbdshim 27-1+b2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | #!/bin/sh
# adjust brightness of the OLPC XO backlight.
# note that brightness is also adjusted automatically by powerd,
# for idle screen dimming and for ambient-light backlight
# control.
usage()
{
echo "usage: ${0##*/} [up|down|max|min|<0-15>|color|mono]"
exit 1;
}
LEVEL=/sys/class/backlight/dcon-bl/brightness # assume DCON
if [ ! -e $LEVEL -a -d /sys/class/backlight ]
then # but then choose the first backlight we find
BACKLIGHT=$(ls /sys/class/backlight | sed 1q )
if [ "$BACKLIGHT" ]
then
# assume levels of 0-15 for now -- use max_brightness later
LEVEL=/sys/class/backlight/$BACKLIGHT/brightness
fi
fi
if [ -e /sys/devices/platform/dcon/monochrome ]
then
MONO_MODE=/sys/devices/platform/dcon/monochrome
elif [ -e /sys/devices/platform/dcon/output ]
then
MONO_MODE=/sys/devices/platform/dcon/output
fi
set_mono()
{
test "$MONO_MODE" && echo 1 > $MONO_MODE
}
set_color()
{
test "$MONO_MODE" && echo 0 > $MONO_MODE
}
MONO_LOCKDIR=/tmp/olpc-brightness
set_mono_mode()
{
# create a directory to hold our flag, so that anyone
# can create or delete it.
mkdir -p $MONO_LOCKDIR
chmod a+w $MONO_LOCKDIR
touch $MONO_LOCKDIR/mono_lock
}
clear_mono_mode()
{
rm -f $MONO_LOCKDIR/mono_lock
}
is_mono_mode()
{
test -e $MONO_LOCKDIR/mono_lock
}
set_bright()
{
echo $1 > $LEVEL
}
read curbright < $LEVEL
case $1 in
# no argument, just report current value
"")
echo $curbright
;;
# set a numeric level. not used much
[0-9]|1[0-5])
set_bright $1
;;
# the next three options set, clear, and test "monochrome
# mode" in this mode, the screen is kept in monochrome mode
# all the time. otherwise, it's set to color when the
# backlight is on, and to monochrome when it's off (i.e., at
# brightness 0)
color)
clear_mono_mode
set_color
;;
mono)
set_mono
set_mono_mode
;;
is_mono)
is_mono_mode || exit 0
exit 1
;;
# used by powerd, to avoid knowing details of "monochrome mode"
maybe_color)
is_mono_mode || set_color
;;
# these two are typically invoked with alt-brightness up/down
max|high)
is_mono_mode || set_color
set_bright 15
;;
min|low)
set_bright 0
set_mono
;;
# the next two are the standard brighten/dim operations.
# dimming to 0 changes from color to monochrome, and
# brightening always switches to color, unless we're in
# "monochrome mode".
up)
newbright=$(( curbright + 1 ))
if [ $newbright -gt 15 ]
then
newbright=15
fi
is_mono_mode || set_color
set_bright $newbright
;;
down)
newbright=$(( curbright - 1 ))
if [ $newbright -le 0 ]
then
set_mono
set_bright 0
else
set_bright $newbright
fi
;;
*)
usage
;;
esac
|