LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Laptop and Netbook (https://www.linuxquestions.org/questions/linux-laptop-and-netbook-25/)
-   -   How do I change screen brightness from a terminal? (https://www.linuxquestions.org/questions/linux-laptop-and-netbook-25/how-do-i-change-screen-brightness-from-a-terminal-882023/)

belltown 05-21-2011 07:34 PM

How do I change screen brightness from a terminal?
 
I'm running Ubuntu 11.04 with the Gnome Classic (No effects) display manager. My laptop's brightness keys work. However, when I boot or resume from suspend when using the integrated Intel graphics card the display brightness is turned all the way down, and I have to turn up the brightness using the brightness function keys so I that can see the display. I'd like to automate this by putting a terminal command in a script so I can automatically turn up the screen brightness when the system boots.

I've tried the following commands with no success:

Code:

echo 9>/sys/class/backlight/acpi_video0/brightness
What ever I echo in the brightness file has no effect on the screen brightness, and nothing changes in the /sys/class/backlight/acpi_video0/brightness or actual_brightness files. The contents of these files do change, however, if I change the brightness using the keyboard function keys.

Code:

setpci -s 00:02.0 F4.B=10
Some posts have suggested this command might work, but in my case it has no effect. The contents of the F4 register remain at 00, even if I change the screen brightness with the function keys.

Code:

xbacklight -set 90
Using this command I can change the value of xbacklight (i.e. xbacklight -get shows the new value), but the screen brightness does not change. However, if I change the screen brightness using the keyboard function keys then the value of xbacklight -get shows the new value.

Code:

acpi_backlight=vendor
I've tried putting this command on the linux command line when I boot. Even with this parameter I'm still unable to change the screen brightness from the terminal. This parameter also disables the keyboard brightness function keys.

Any suggestions of anything else I could try to change the screen brightness from a terminal?

Snark1994 05-22-2011 03:04 PM

I would look under the Gnome keyboard shortcut configuration, if I remember rightly from when I used Ubuntu you can see what command it runs when you press the brightness keys :) and then you should be able to run that from terminal...

roygbiiv 05-23-2011 09:35 AM

Quote:

Code:

echo 9>/sys/class/backlight/acpi_video0/brightness
What ever I echo in the brightness file has no effect on the screen brightness, and nothing changes in the /sys/class/backlight/acpi_video0/brightness or actual_brightness files. The contents of these files do change, however, if I change the brightness using the keyboard function keys.
does this work?
Code:

sudo echo 9>/sys/class/backlight/acpi_video0/brightness
remember you can only echo values 0-24 (0 darkest - 24 brightest). i use a bash script that i run with sudo for this purpose. it takes the brightness level as argument:

Code:

#!/bin/bash
# set screen brightness level

if [ "$#" = "0" ]; then
        level= cat /sys/class/backlight/acpi_video0/brightness
        echo -n $level
else
        echo  $1 > /sys/class/backlight/acpi_video0/brightness
fi


belltown 05-24-2011 12:07 PM

Quote:

Originally Posted by Snark1994 (Post 4363910)
I would look under the Gnome keyboard shortcut configuration, if I remember rightly from when I used Ubuntu you can see what command it runs when you press the brightness keys :) and then you should be able to run that from terminal...

No, there are no keyboard shortcut keys for the brightness controls. I've found some configurable settings under gconf-editor in the Gnome Power Manager, but nothing tells me what Gnome is using to set the brightness.

belltown 05-24-2011 12:15 PM

Quote:

Originally Posted by roygbiiv (Post 4364604)
does this work?
Code:

sudo echo 9>/sys/class/backlight/acpi_video0/brightness
remember you can only echo values 0-24 (0 darkest - 24 brightest). i use a bash script that i run with sudo for this purpose. it takes the brightness level as argument:

Code:

#!/bin/bash
# set screen brightness level

if [ "$#" = "0" ]; then
        level= cat /sys/class/backlight/acpi_video0/brightness
        echo -n $level
else
        echo  $1 > /sys/class/backlight/acpi_video0/brightness
fi


That doesn't work. I can access the acpi brightness file, but any value I try to echo into that file has no effect, e.g:

Code:

root@john-laptop:/home/john# sudo su
root@john-laptop:/home/john# cat /sys/class/backlight/acpi_video0/brightness
10
root@john-laptop:/home/john# echo 5> /sys/class/backlight/acpi_video0/brightness

root@john-laptop:/home/john# cat /sys/class/backlight/acpi_video0/brightness
10


Evgenii Frolov 03-20-2013 12:10 AM

Worked for me!
 
Quote:

Originally Posted by belltown (Post 4365788)
That doesn't work. I can access the acpi brightness file, but any value I try to echo into that file has no effect, e.g:

Code:

root@john-laptop:/home/john# sudo su
root@john-laptop:/home/john# cat /sys/class/backlight/acpi_video0/brightness
10
root@john-laptop:/home/john# echo 5> /sys/class/backlight/acpi_video0/brightness

root@john-laptop:/home/john# cat /sys/class/backlight/acpi_video0/brightness
10


This worked for me!!! Add quotes around a number!!!
Code:

sudo echo "9">/sys/class/backlight/acpi_video0/brightness
Quote:

Originally Posted by roygbiiv (Post 4364604)
does this work?
Code:

sudo echo 9>/sys/class/backlight/acpi_video0/brightness
remember you can only echo values 0-24 (0 darkest - 24 brightest). i use a bash script that i run with sudo for this purpose. it takes the brightness level as argument:

For me it is 0-20 range!

tcuc 09-17-2014 03:50 AM

Worked great! as root...
 
this worked great:
Code:

echo "24">/sys/class/backlight/acpi_video0/brightness
but how can i do this as a regular user?
I want to bind this to a hotkey in openbox but i cant exactly do stuff as root there.

Evgenii Frolov 09-17-2014 04:28 AM

Quote:

Originally Posted by tcuc (Post 5239556)
but how can i do this as a regular user?
I want to bind this to a hotkey in openbox but i cant exactly do stuff as root there.

You should use "xbacklight" package then. If you have it installed then first of all see
Code:

man xbacklight
. There you can find, e.g.
Code:

xbacklight -inc 20
It increases brightness on 20%. It is the best way.
xbacklight man page on-line.

tcuc 09-17-2014 06:43 AM

Perfect!
 
that was perfect! thanks allot!

Evgenii Frolov 09-17-2014 08:01 AM

Quote:

Originally Posted by tcuc (Post 5239620)
that was perfect! thanks allot!

You are wellcome! Have a nice linux time and smooth workflow with it (=

feeling 01-06-2015 04:24 AM

Hi, I'm new at linux and got a similiar problem:

Hotkeys won't work.
(sudo) echo xx>/sys... gives bash: /sys/class/backlight/acpi_video0/brightness: Permission denied
(sudo) echo "xx">/sys... gives the same
btw: brightness has -rw-r--r--

then I installed xbacklight
but no matter what I wrote in commandline (xbacklight -get, xbacklight -set 10, xbacklight -inc 20, ...) nothing happens nor output.
Can someone help me?

I'm working on a Thinkpad Edge something with Linux Mint 17 and cinnamon


Please feel free to correct my english so that I can improve it.

Head_on_a_Stick 01-06-2015 01:53 PM

Code:

sudo tee /sys/class/backlight/acpi_video0/brightness <<< "value"
EDIT: Your English is very good, but it should be:
"and I have a similar problem"
"nothing happens and there is no output"
;)

feeling 01-06-2015 03:13 PM

Your code gives just out 1 or 5 or 10 or whatever I wrote for value. But the actual brightness doesn't change.
Do you have more suggestions, maybe?


Thanks anyway

Head_on_a_Stick 01-06-2015 03:20 PM

What is the output of:
Code:

ls /sys/class/backlight
If there are other backlight folders, try modifying the "brightness" file in there instead.

Which kernel version and graphics card are you using?

feeling 01-06-2015 06:34 PM

great, the command aplied on ...radeon_bl0/brightness works.
thanks for that hind.

Quote:

Originally Posted by Head_on_a_Stick (Post 5296602)
Which kernel version and graphics card are you using?

3.13.0-24-generic and [AMD/ATI] Kabini [Radeon HD 8240]
But I think that doesn't matter anymore.

Thanks for your help. Good night


All times are GMT -5. The time now is 09:36 PM.