How to adjust brightness in Trisquel mini

16 respostas [Última entrada]
Anandawardhana
Desconectado
Joined: 09/18/2012

Hello, I just installed Trisquel mini 7 on a NEC versapro vy10a/c-3 netbook. I am unable to adjust the brightness using the function key or xbacklight. Brightness always remains at the highest point, and I find it extremely tiring when I use it continuously for a couple of hours

I've been using Trisquel 6 on a different laptop and it has no issue in adjusting the brightness. I cannot remember whether I had the same issue with it when I first installed (or if I got it fixed at some point).

How to fix this problem?

ADFENO
Desconectado
Joined: 12/31/2012

Does your computer, by chance, use an Nvidia graphics?

I recall that sometimes the system doesn't find which text file is
needed to change the brightness.

I'm not a programmer, but I might come up with something to help you
out. I just have to find out which text file needs to be changed.

loldier
Desconectado
Joined: 02/17/2016

Try this or something similar along these lines http://unix.stackexchange.com/questions/190464/how-to-change-brightness-on-puppy-linux (you may have to find the min/max values):

https://trisquel.info/en/forum/toutatis-brightness-control#comment-57912

echo 500 | sudo tee /sys/class/backlight/intel_backlight/brightness

To make it permanent, you may have to edit /etc/rc.local.

http://askubuntu.com/questions/151651/brightness-is-reset-to-maximum-on-every-restart

This might be relevant (elevated permissions).

http://superuser.com/questions/484678/cant-write-to-file-sys-class-backlight-acpi-video0-brightness-ubuntu

lembas
Desconectado
Joined: 05/13/2010

What is the output of find /sys -iname brightness

Anandawardhana
Desconectado
Joined: 09/18/2012

The output is :

/sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-LVDS-1/intel_backlight/brightness
/sys/devices/pci0000:00/0000:00:02.0/backlight/acpi_video0/brightness
/sys/devices/pci0000:00/0000:00:1c.0/0000:02:00.0/leds/phy0-led/brightness
/sys/devices/pci0000:00/0000:00:1e.0/0000:03:05.1/leds/mmc0::/brightness
find: `/sys/kernel/debug': Permission denied

loldier
Desconectado
Joined: 02/17/2016

It's Intel, so you can use this. Use a lower value.

echo 60 | sudo tee /sys/class/backlight/intel_backlight/brightness

It must be given as root. The 'sudo tee' part does that (prompts for your administrative password).

Anandawardhana
Desconectado
Joined: 09/18/2012

Great! It works! Thanks very much!

When I restart the machine it goes back to full brightness. How can I make it permanent?

loldier
Desconectado
Joined: 02/17/2016
Anandawardhana
Desconectado
Joined: 09/18/2012

Perfect! It's done :-)

Thanks very much for all the helpful pointers and input loldier, lembas and ADFENO!

Anandawardhana
Desconectado
Joined: 09/18/2012

Oh, I think you have shown it in your previous reply. I'll give it a try. Thanks very much again! :-)

loldier
Desconectado
Joined: 02/17/2016

Namely:

sudo nano /etc/rc.local

Add line

echo X > /sys/class/backlight/intel_backlight/brightness

above 'exit 0'

Where 'X' is a value that you find satisfactory when applying the sudo tee command.

Save and exit: Ctrl+x, y, enter and reboot

Anandawardhana
Desconectado
Joined: 09/18/2012

I'm currently using 1500 as the value there. What does this number mean? What is the unit we use here? I'm just curious because it isn't a percentage.

loldier
Desconectado
Joined: 02/17/2016

It's a range min/max, a vendor/hardware based specific value. I don't think it has any relevance.

You should be able to determine the maximum:

cat /sys/class/backlight/acpi_video0/max_brightness

ADFENO
Desconectado
Joined: 12/31/2012

I have made a small example script that can aid on using the function
keys to change the brightness. This script assumes that the system is
using Nvidia GPU/graphics, so change it accordingly. Look for "End of
file" to see where this script ends.

In order for everything to work nicely, we need to place the script
inside "/etc/acpi/", and this place is generally meant to be used by
administrators of the system. That said, in this example we'll be using
GNU nano to edit the script (if you want to use other text editor, and
if it's a graphical one, use "gksudo" instead of "sudo"), so open a
terminal and do (you can remove the "$ ", it's just a way to tell you
what must be done):

Note: You can change the name of the script
("acpi-to-nouveau-backlight-brightness.sh") to anything you want, just
remember the name because we'll need it later on.

$ sudo nano "/etc/acpi/acpi-to-nouveau-backlight-brightness.sh"

"sudo" and "gksudo" will ask for your user's password, and you'll
probably not be able to see it being typed.

Then, once your password is correct, GNU nano should show up. Then, copy
and paste the script bellow. If you're reading this in a terminal: use
Ctrl + Shift + C, instead of Ctrl + C, to copy the text; and use Ctrl +
Shift + V, instead of Ctrl + V to paste the text.

# Begin of file. Remove this line.
#!/bin/bash
# The line above starts the script and tells the system to use GNU Bash
to read the commands.

# Associative arrays must be created with "declare -A".
declare -A acpi_video
declare -A nv_backlight

acpi_video[path]="/sys/class/backlight/acpi_video0"
nv_backlight[path]="/sys/class/backlight/nv_backlight"

# If both directories don't exist...
if [[ ! -d "${acpi_video[path]}" || ! -d "${nv_backlight[path]}" ]]
then
# Do nothing and exit with status "1".
exit 1
fi

# Sets minimum brightness.
min_brightness=0
# Takes maximum brightness value from ACPI's video and Nvidia GPU.
acpi_video[max_brightness]="$(cat "${acpi_video[path]}/max_brightness")"
nv_backlight[max_brightness]="$(cat
"${nv_backlight[path]}/max_brightness")"
# Takes the current brightness value from ACPI video and Nvidia GPU.
acpi_video[brightness]="$(cat "${acpi_video[path]}/brightness")"
nv_backlight[brightness]="$(cat "${nv_backlight[path]}/brightness")"

# Needed so that we don't have to watch the ACPI backlight brightness
# every time, and so that the Nouveau backlight brightness matches the
# ACPI one.
# We accomplish this by doing proportionality calculation.
nv_backlight[brightness]="$(( ( ${acpi_video[brightness]} *
${nv_backlight[max_brightness]} ) / ${acpi_video[max_brightness]} ))"

# A "step" in this script is done every time the ACPI brightness is
changed. ACPI backlight brightness has a fixed step of 1. This means
that everytime you press the brightness key, you are modifying the
brightness by value "1", either negative or positive.
# Needed to convert an ACPI backlight brightness step to a Nouveau
backlight
# brightness step.
acpi_video_to_nv_backlight_step="$(( ( 1 *
${nv_backlight[max_brightness]} ) / ${acpi_video[max_brightness]} ))"

# If the script receives the word "down"...
if [[ "${1}" == "down" ]]
then
# Steps down on the Nvidia backlight brightness.
nv_backlight[brightness]="$(( ( ( ${acpi_video[brightness]} *
${nv_backlight[max_brightness]} ) / ${acpi_video[max_brightness]} ) -
acpi_video_to_nv_backlight_step ))"
# Else if the word received is "up"...
elif [[ "${1}" == "up" ]]
then
# Steps up on the Nvidia backlight brightness.
nv_backlight[brightness]="$(( ( ( ${acpi_video[brightness]} *
${nv_backlight[max_brightness]} ) / ${acpi_video[max_brightness]} ) +
acpi_video_to_nv_backlight_step ))"
fi

# Let's make sure that the Nvidia brightness is not negative.
if [[ "${nv_backlight[brightness]}" -lt "${min_brightness}" ]]
then
nv_backlight[brightness]="${min_brightness}"
# And not way beyond what the maximum brightness is supposed to be.
elif [[ "${nv_backlight[brightness]}" -gt
"${nv_backlight[max_brightness]}" ]]
then
nv_backlight[brightness]="${nv_backlight[max_brightness]}"
fi

# Finally, let's make things work...
# Sets the Nvidia GPU brightness to the one calculated by this script.
echo "${nv_backlight[brightness]}" > "${nv_backlight[path]}/brightness"
# End of file. Remove this line.

Inside GNU nano, press Ctrl + X (labeled as "^X" on the bottom) to quit.
You'll be asked if you want to save the file, do so.

Now, we'll set the permissions of the file, by doing:

Note: If you have changed the name of the file, do so here too.

$ sudo chmod "+rx" "/etc/acpi/acpi-to-nouveau-backlight-brightnes"

Now we set which user and group are the owners of the file:

Note: If you have changed the name of the file, do so here too.

$ sudo chown "root:root" "/etc/acpi/acpi-to-nouveau-backlight-brightnes"

After doing this, we must now find out what the software responsible for
ACPI control is seeing when you press the brightness keys, because,
apparently we didn't tell how to recognize the key yet.

To have a chance to see which key is seen by the ACPI controller, one
can do:

$ acpi_listen

From now on until you press Ctrl + C (terminate the process),
acpi_listen will print what it sees each time you press a function key.

In my case, since I'm using a Sony laptop, every time I press the
"brightness up" key, acpi_listen prints three lines, each starting with:

video/brightnessup
sony/hotkey
sony/hotkey

If, like in my case, you see "video/brightnessup" in one of the lines,
you can take note of "video/brightnessup" (make sure that acpi_listen
sees "video/brightnessdown" every time you press the "brightness down"
function key too) and, in this case, you don't need to take note of the
letters or numbers that appear after that.

As I said earlier, and once your notes are taken, press Ctrl + C to
quit/terminate acpi_listen.

Now we'll begin telling the ACPI controller what it must do every time
we press the keys. So, for the "brightness down" function key, do:

Note: You can change the name of the files.

$ sudo nano "/etc/acpi/events/acpi-to-nouveau-backlight-brightness-down"

And write this inside:

Note: If you have changed the name of the very first script, do so here
too.

# Begin of file. Remove this line.
event=video/brightnessdown
action=/etc/acpi/acpi-to-nouveau-backlight-brightness.sh down
# End of file. Remove this line.

Now, save and exit GNU nano.

Now, we do the same for the "brightness up" function key:

Note: You can change the name of the files.

$ sudo nano "/etc/acpi/events/acpi-to-nouveau-backlight-brightness-up"

And so we write the following text inside:

Note: If you have changed the name of the very first script, do so here
too.

# Begin of file. Remove this line.
event=video/brightnessup
action=/etc/acpi/acpi-to-nouveau-backlight-brightness.sh up
# End of file. Remove this line.

Finally, we do:

$ sudo service acpid stop
$ sudo service acpid start

And we're done!

I wish you success on all your free software activism!

Anandawardhana
Desconectado
Joined: 09/18/2012

Thanks very much for this! I will give it a try.

At the moment I am using the solution suggested by loldier. It doesn't enable the function key combinations though.

tonlee
Desconectado
Joined: 09/08/2014

On a notebook brightness keys would work if debian 8 installed. Not if ubuntu 14.04 installed.

To make brigtness keys work if ubuntu installed I used these instructions.
https://itsfoss.com/fix-brightness-ubuntu-1310/
Works if graphic is intel.
If computer is restarted then set brightness is forgotten. Brightness keys works after restart.

Does echo X > /sys/class/backlight/intel_backlight/brightness make brightness keys work or only set it?

loldier
Desconectado
Joined: 02/17/2016

The echo command only dims or brightens the display temporarily (unless written in a file that gets executed at boot). It has no effect on the keybindings.