How to make the screen brightness keys work again in KDE: Difference between revisions

From www.ReeltoReel.nl Wiki
Jump to navigation Jump to search
No edit summary
Line 35: Line 35:
Note that I increase the value by 10 otherwise it would not change enough. You can vary that value of course to get finer control or get faster adjustment.
Note that I increase the value by 10 otherwise it would not change enough. You can vary that value of course to get finer control or get faster adjustment.
I put the script in my home bin directory:
I put the script in my home bin directory:
  #vi ~/bin/brp
  user> vi ~/bin/brp


I called it 'brp' which is nice and short and stands for ''''br'''ightness '''p'''lus'
I called it 'brp' which is nice and short and stands for ''''br'''ightness '''p'''lus'


I created a similar script called brm which decreases the value:
I created a similar script called brm which decreases the value:
  #vi ~/bin/brm
  user> vi ~/bin/brm
And paste the content
And paste the content
<pre>
<pre>
Line 47: Line 47:
echo $br > /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card0/card0-LVDS-1/radeon_bl0/brightness
echo $br > /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card0/card0-LVDS-1/radeon_bl0/brightness
<pre>
<pre>
Now, the problem is that this file '''/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card0/card0-LVDS-1/radeon_bl0/brightness''' may only be written by root. Notice that all commands manipulating the file so far have been executed as root.

Revision as of 15:39, 9 November 2015

How to make button for screen brightness work on your laptop in KDE

When I started using a newer kernel in openSUSE 13.2, I noticed the buttons for screen brightness were no longer functioning on my laptop. This is verry annoying, so I decided to do something about it. I am using KDE. I will try to write the instructions as generic as possible, so that it will hopefully work in your situation too. This is a HP ELitebook 8570p.

First, we have to find the screen device, which is located somewhere in the /sys/devices/pci0000:00 directory.

Somewhere in this directory is a file located with the name 'brightness'. Let's find it.

#find /sys/devices/pci0000:00 -name "brightness"
/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card0/card0-LVDS-1/radeon_bl0/brightness
/sys/devices/pci0000:00/0000:00:1c.2/0000:24:00.1/leds/mmc0::/brightness
/sys/devices/pci0000:00/0000:00:1c.3/0000:25:00.0/leds/phy0-led/brightness

Remember, your output is probably different from what I got here.

I have a radeon card, so the first line contains the device we will be working with.

When you read the content of the 'file', you get the current brightness level:

#cat /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card0/card0-LVDS-1/radeon_bl0/brightness
235

The value lies somewhere between 0 and 255, it's a one byte value.

You can test if this work for you by writing a different value to that file: (remeber to substitute the file for your graphics card)

#echo 200 > /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card0/card0-LVDS-1/radeon_bl0/brightness

If this works, you should see the brightness change, and you can go to the next step.

I created a simple QAD(quick and Dirty) 3 line script to read that value and increase it:

br=$(cat /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card0/card0-LVDS-1/radeon_bl0/brightness)
br=$((br+10))
echo $br > /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card0/card0-LVDS-1/radeon_bl0/brightness

Note that I increase the value by 10 otherwise it would not change enough. You can vary that value of course to get finer control or get faster adjustment. I put the script in my home bin directory:

user> vi ~/bin/brp

I called it 'brp' which is nice and short and stands for 'brightness plus'

I created a similar script called brm which decreases the value:

user> vi ~/bin/brm

And paste the content

br=$(cat /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card0/card0-LVDS-1/radeon_bl0/brightness)
br=$((br-10))
echo $br > /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card0/card0-LVDS-1/radeon_bl0/brightness

Now, the problem is that this file /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card0/card0-LVDS-1/radeon_bl0/brightness may only be written by root. Notice that all commands manipulating the file so far have been executed as root.