2

My Macbook Air 2013 power lasts 1.5 hours with just too bright light. More than 7 hours with normal light (that is 30-40% of the current max) corresponding to my default brightness in OS X where the battery lasts 7-9 hours. I would like to have a one-liner of gsettings to make the change. There is a rapid jump in power consumption of display depending on the setting. I would like to find the optimum one for power consumption and usability.

I do

git clone https://github.com/patjak/mba6x_bl
Cloning into 'mba6x_bl'...
remote: Counting objects: 140, done.
remote: Total 140 (delta 0), reused 0 (delta 0), pack-reused 140
Receiving objects: 100% (140/140), 45.12 KiB | 0 bytes/s, done.
Resolving deltas: 100% (76/76), done.
Checking connectivity... done.

masi@masi:~/jacob$ cd mba6x_bl/

masi@masi:~/jacob/mba6x_bl$ make
make -C /lib/modules/4.4.0-22-generic/build M=/home/masi/jacob/mba6x_bl modules
make[1]: Entering directory '/usr/src/linux-headers-4.4.0-22-generic'
  CC [M]  /home/masi/jacob/mba6x_bl/mba6x_bl.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/masi/jacob/mba6x_bl/mba6x_bl.mod.o
  LD [M]  /home/masi/jacob/mba6x_bl/mba6x_bl.ko
make[1]: Leaving directory '/usr/src/linux-headers-4.4.0-22-generic'

masi@masi:~/jacob/mba6x_bl$ sudo make install
make -C /lib/modules/4.4.0-22-generic/build M=/home/masi/jacob/mba6x_bl modules_install
make[1]: Entering directory '/usr/src/linux-headers-4.4.0-22-generic'
  INSTALL /home/masi/jacob/mba6x_bl/mba6x_bl.ko
At main.c:222:
- SSL error:02001002:system library:fopen:No such file or directory: bss_file.c:175
- SSL error:2006D080:BIO routines:BIO_new_file:no such file: bss_file.c:178
sign-file: certs/signing_key.pem: No such file or directory
  DEPMOD  4.4.0-22-generic
make[1]: Leaving directory '/usr/src/linux-headers-4.4.0-22-generic'

where the errors are harmless. The result works in my system! Here is a ticket about the case.

Laptop: Macbook Air 2013-mid (6.2)
Ubuntu versions: 16.04
Linux kernel: 4.4 and 4.6
Status: deprecated feature request (RESOLVED NOTOURBUG) because no resources for the development for the adjustment of Apple Hardware for Linux at least on the Intel side. However, Patrik Jacobsen is working with it.

2 Answers 2

1

I can't get gsettings to change the brightness on my laptop running Ubuntu 16.06, but I can change the brightness by storing a value in /sys/class/backlight/device-name/brightness where device-name is one of the video devices listed in /sys/class/backlight. In each of these directories there is a max_brightness file. To write to these files you will need to be root. So in my case, using the first of the 3 device directories (which in my case is acpi_video0),

$ ls /sys/class/backlight    # shows the video devices
acpi_video0    acpi_video1    radeon_bl0
$ cat /sys/class/backlight/acpi_video0/brightness   # shows current level
7
$ cat /sys/class/backlight/acpi_video0/max_brightness   # shows max level
10
$ sudo sh   # become super-user
# echo 3 > /sys/class/backlight/acpi_video0/brightness   # dim screen
# echo 10 > /sys/class/backlight/acpi_video0/brightness   # max brightness
# exit   # return to unprivileged user
$ sudo sh -c "echo 10 > /sys/class/backlight/acpi_video0/brightness"

The final line above gives a "one-liner" brightness change command.

You could extend this if desired to compute a fraction of brightness required based on max_brightness using the expr command.

P.S. My laptop is an Intel Compaq CQ62 so this may not solve the problem on a Macbook.

5
  • How can you set the brightness to 30% of the default value? Is it sudo sh -c "echo 3 > /sys/class/backlight/acpi_video0/brightness"? Commented Jun 8, 2016 at 15:27
  • Yes, that works on my laptop but if you don't have an acpi_video0 directory you'll have to adapt the command accordingly. Commented Jun 8, 2016 at 19:39
  • Yes, I have the same directory in 16.04. The value changes there dynamically when you make changes in your keyboard. It would be great to scale this value always like by 1/2. I think you cannot do it with the file itself. There has to be something by which you can control it dynamically. I do not understand the fine details enough for the answer. Commented Jun 8, 2016 at 19:49
  • 1
    Try reading (wiki.archlinux.org/index.php/backlight) for general info on Linux backlight approaches. You may be able to install and use xbacklight to set a 50% value, but I don't see a way of changing the maximum (so scaling as you wish). Commented Jun 9, 2016 at 20:00
  • Can systemd-backlight handle such a permanent scaling to 50%? Let the user have the scaling normally but all his/her values are scaled by 50%. Commented Jun 9, 2016 at 20:03
0

Just do which works in most cases of Macbook 6.2

git clone https://github.com/patjak/mba6x_bl && cd mba6x_bl/ && make && make install

The errors about SSL are harmless.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .