~vanvugt/mir/wake-lock-on-input

« back to all changes in this revision

Viewing changes to src/utils/backlight.sh

  • Committer: Tarmac
  • Author(s): Daniel van Vugt
  • Date: 2015-06-15 11:34:26 UTC
  • mfrom: (2656.3.2 mirbacklight)
  • Revision ID: tarmac-20150615113426-w9orcna8yl75tf9m
Introducing mirbacklight: A simple script mostly for use in development,
but also useful enough to be included in mir-utils.

By default it finds all backlights and sets them to max brightness. If
given a parameter, that will be interpreted as a percentage brightness.

Tested on: krillin, arale, mako, thinkpad

Warning: Arale has a bug where it interprets 100% as zero (off). So you
need to use 99 on arale. Fixes: https://bugs.launchpad.net/bugs/1464094.

Approved by Alexandros Frantzis, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
#
 
3
# Copyright © 2015 Canonical Ltd.
 
4
#
 
5
# This program is free software: you can redistribute it and/or modify
 
6
# it under the terms of the GNU General Public License version 3 as
 
7
# published by the Free Software Foundation.
 
8
#
 
9
# This program is distributed in the hope that it will be useful,
 
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
# GNU General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU General Public License
 
15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
#
 
17
# Author: Daniel van Vugt <daniel.van.vugt@canonical.com>
 
18
#
 
19
 
 
20
if [ -z "$1" ] ; then
 
21
    percent=100
 
22
else
 
23
    percent=$1
 
24
fi
 
25
 
 
26
for devdir in /sys/class/backlight/* /sys/class/leds/lcd-backlight ; do
 
27
    if [ -d "$devdir" ] ; then
 
28
        max=`cat $devdir/max_brightness`
 
29
        val=$(($max * $percent / 100))
 
30
        echo $val > $devdir/brightness
 
31
        echo "Set backlight $devdir to $percent% ($val/$max)"
 
32
    fi
 
33
done