Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
lenovo X230 - ACPI -Fn+key- brightness control [SOLVED]
View unanswered posts
View posts from last 24 hours

Goto page 1, 2  Next  
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
OneNoteMan
n00b
n00b


Joined: 28 Sep 2018
Posts: 11

PostPosted: Fri Sep 28, 2018 7:54 pm    Post subject: lenovo X230 - ACPI -Fn+key- brightness control [SOLVED] Reply with quote

EDIT: This is now solved. I wanted to also make note for other x230 owners out there as I know it is popular laptop..
I am running a lenovo thinkpad x230, with the older legendary x220 keyboard, I modded the bios to fix the keymapping, and with gentoo, all the keys and Fn+keys are functioning.

Hi
I am still fairly new to gentoo and linux in general.

I have everything up and running the only thing that doesnt work are my fn+keys, and special keys

my keys cannot control volume, brightness,

my laptop:
Lenovo ThinkPad X230, and i am running xmonad on it


when i run acpi_listen, i do get inputs for each keys, so it seems they are registering but not actually doing anything. They are all mismatched from the actual keyboard but its there nonetheless.

The only special function keys that work are the fn+f5 which toggles on and off the wifi, unfortunately this is the most uesless one out of all of them.

I followed this wiki to a T:
https://wiki.gentoo.org/wiki/ACPI/ThinkPad-special-buttons

Dmesg output:
https://paste.pound-python.org/show/djwn8Q3jvSkZlxdNuxTk/

thinkpad related config options:
https://paste.pound-python.org/show/kuqjUT4jcy4Mgy84PCgQ/


Last edited by OneNoteMan on Sat Sep 29, 2018 4:36 pm; edited 1 time in total
Back to top
View user's profile Send private message
Anon-E-moose
Advocate
Advocate


Joined: 23 May 2008
Posts: 3485
Location: Dallas area

PostPosted: Fri Sep 28, 2018 8:04 pm    Post subject: Reply with quote

This might help https://forums.gentoo.org/viewtopic-t-1085854-highlight-.html
_________________
Asus m5a99fx, FX 8320 - nouveau & radeon, oss4
Acer laptop E5-575, i3-7100u - i965, alsa
---both---
4.14.62 kernel, profile 17.0 (no-pie) amd64-no-multilib
gcc 7.3.0, eudev, openrc, openbox, palemoon
Back to top
View user's profile Send private message
OneNoteMan
n00b
n00b


Joined: 28 Sep 2018
Posts: 11

PostPosted: Fri Sep 28, 2018 8:08 pm    Post subject: Reply with quote

do I need xbacklight though?

I already have the lenovo ACPI driver, its just not functioning properly
Back to top
View user's profile Send private message
Anon-E-moose
Advocate
Advocate


Joined: 23 May 2008
Posts: 3485
Location: Dallas area

PostPosted: Fri Sep 28, 2018 8:11 pm    Post subject: Reply with quote

That thread was more about how to set acpi to recognize things like the fn keys.
_________________
Asus m5a99fx, FX 8320 - nouveau & radeon, oss4
Acer laptop E5-575, i3-7100u - i965, alsa
---both---
4.14.62 kernel, profile 17.0 (no-pie) amd64-no-multilib
gcc 7.3.0, eudev, openrc, openbox, palemoon
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6229
Location: Room 101

PostPosted: Fri Sep 28, 2018 8:47 pm    Post subject: Reply with quote

OneNoteMan wrote:
do I need xbacklight though?

OneNoteMan ... no, all you need is a backlight script and inform acpid (via /etc/acpid/default.sh) that it should run this on recieving 'brightnessup' and 'brightnessdown'. The linked post should cover everything, but if you have any questions, ask.

best ... khay
Back to top
View user's profile Send private message
OneNoteMan
n00b
n00b


Joined: 28 Sep 2018
Posts: 11

PostPosted: Fri Sep 28, 2018 11:40 pm    Post subject: Reply with quote

I tried to modify the script but it still isnt working

my default.sh is here:

https://paste.pound-python.org/show/DfjVcXOI3pKBY7KW6fzl/

I have also done chmod +x on the scripts

I am not very experienced in bash, so im not sure if its correct. I installed linux to learn bash more.

not sure why it still isnt working.

I tried to run the script directly by typing
./backlight.sh down
but its saying command not found line 17
I copied and pasted the backlight script exact though
Back to top
View user's profile Send private message
Anon-E-moose
Advocate
Advocate


Joined: 23 May 2008
Posts: 3485
Location: Dallas area

PostPosted: Fri Sep 28, 2018 11:49 pm    Post subject: Reply with quote

what does "ls /sys/class/backlight/" return?

if it shows intel_backlight then what does "ls /sys/class/backlight/intel_backlight" return?
_________________
Asus m5a99fx, FX 8320 - nouveau & radeon, oss4
Acer laptop E5-575, i3-7100u - i965, alsa
---both---
4.14.62 kernel, profile 17.0 (no-pie) amd64-no-multilib
gcc 7.3.0, eudev, openrc, openbox, palemoon
Back to top
View user's profile Send private message
OneNoteMan
n00b
n00b


Joined: 28 Sep 2018
Posts: 11

PostPosted: Fri Sep 28, 2018 11:53 pm    Post subject: Reply with quote

Anon-E-moose wrote:
what does "ls /sys/class/backlight/" return?

if it shows intel_backlight then what does "ls /sys/class/backlight/intel_backlight" return?


ls /sys/class/backlight/

gives:
intel_backlight

ls /sys/class/backlight/intel_backlight

gives:
actual_brightness
bl_power
brightness
device
max_brightness
power
subsystem
type
uevent
Back to top
View user's profile Send private message
Anon-E-moose
Advocate
Advocate


Joined: 23 May 2008
Posts: 3485
Location: Dallas area

PostPosted: Sat Sep 29, 2018 12:02 am    Post subject: Reply with quote

I don't see curr_brightness which is probably why it doesn't work. change it to actual_brightness in the brightness.sh script and see if it works
_________________
Asus m5a99fx, FX 8320 - nouveau & radeon, oss4
Acer laptop E5-575, i3-7100u - i965, alsa
---both---
4.14.62 kernel, profile 17.0 (no-pie) amd64-no-multilib
gcc 7.3.0, eudev, openrc, openbox, palemoon
Back to top
View user's profile Send private message
OneNoteMan
n00b
n00b


Joined: 28 Sep 2018
Posts: 11

PostPosted: Sat Sep 29, 2018 2:32 am    Post subject: Reply with quote

I tried to make the changes to the file but im getting an error

cp: cannot create regular file

it appears that i only have read permisson to anything in the folder
/sys/class/backlight/intel_backlight

this doesnt make sense because im trying yo make these modifications as root

of course i couldnt chmod it because even as root permission is denied

ls -a /sys/class/backlight/intel_backlight ..results here:
https://paste.pound-python.org/show/L5e8vjOWdwIdL8aNbUyb/

I suspect that this also may be the reason i am not able to change brightness, since I only have read permission?

im not sure why this is I certain my partitions are set up correctly, as it is exactly like the handbook specifies
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6229
Location: Room 101

PostPosted: Sat Sep 29, 2018 8:30 am    Post subject: Reply with quote

Anon-E-moose wrote:
I don't see curr_brightness which is probably why it doesn't work. change it to actual_brightness in the brightness.sh script and see if it works

Anon-E-moose ... no, 'current_brightness' is a variable that reads in the contents of 'brightness' ... and that exists under /sys/class/backlight/intel_backlight.

OneNoteMan wrote:
I tried to make the changes to the file but im getting an error

Code:
cp: cannot create regular file

You shouldn't need to make any changes to the script, but ok, from what command is that error produced? ... because the script doesn't include a 'cp', so that must come from elsewhere.

OneNoteMan wrote:
it appears that i only have read permisson to anything in the folder /sys/class/backlight/intel_backlight

No, the files which are non-modifiable (ie, which contain a state ... such as 'actual_brightness' and 'max_brightness') are read only, but the file 'brightness', which is the only file modified by the script, is +rw.

So, just place an un-modified backlight.sh in /etc/acpi/actions with u+x, then fn+brightness down, and fn+brightnessup, that should work.

BTW, it's not "bash", the script is written in posix sh.

EDIT: actually, there is a problem there with the test condition ... try the following:

/etc/acpi/actions/backlight.sh:
#!/bin/sh

set -e

backlight_sys_dir="/sys/class/backlight/intel_backlight"

read -r max_brightness < "${backlight_sys_dir}/max_brightness"
read -r curr_brightness < "${backlight_sys_dir}/brightness"

case "$1" in
      up) increment="+ 10" ;;
    down) increment="- 10" ;;
       *) exit 1 ;;
esac

new_brightness=$(($curr_brightness $increment))

if [ $new_brightness -lt 1 ] || [ $new_brightness -gt $max_brightness ]; then
    exit 1
else
    echo "$new_brightness" > ${backlight_sys_dir}/brightness
fi

best ... khay
Back to top
View user's profile Send private message
Anon-E-moose
Advocate
Advocate


Joined: 23 May 2008
Posts: 3485
Location: Dallas area

PostPosted: Sat Sep 29, 2018 11:42 am    Post subject: Reply with quote

khayyam wrote:
Anon-E-moose ... no, 'current_brightness' is a variable that reads in the contents of 'brightness' ... and that exists under /sys/class/backlight/intel_backlight.


:oops: Sorry I was already nodding off when I made that reply.
_________________
Asus m5a99fx, FX 8320 - nouveau & radeon, oss4
Acer laptop E5-575, i3-7100u - i965, alsa
---both---
4.14.62 kernel, profile 17.0 (no-pie) amd64-no-multilib
gcc 7.3.0, eudev, openrc, openbox, palemoon
Back to top
View user's profile Send private message
josephg
l33t
l33t


Joined: 10 Jan 2016
Posts: 777
Location: usually offline

PostPosted: Sat Sep 29, 2018 12:43 pm    Post subject: Reply with quote

OneNoteMan wrote:
I tried to run the script directly by typing
./backlight.sh down
but its saying command not found line 17

what is the output of
Code:
$ ls -lh ./backlight.sh

Code:
$ cat ./backlight

_________________
"Growth for the sake of growth is the ideology of the cancer cell." Edward Abbey
Back to top
View user's profile Send private message
OneNoteMan
n00b
n00b


Joined: 28 Sep 2018
Posts: 11

PostPosted: Sat Sep 29, 2018 2:37 pm    Post subject: Reply with quote

so there is nothing wrong with the permissions as per khayyam

i was trying to rename the actual_brightness by using cp and then rm, but that is not needed.

I have tried doing the adjustments as stated but still no luck :(

Oh I should also mention the power button led is off, it is generally on when my system is on, it still functions though. Maybe this is a clue, i am not sure. I dont care much for the leds, I just want the buttons to work.

I tried to redo the instructions:
https://wiki.gentoo.org/wiki/ACPI/ThinkPad-special-buttons

I tried logging in as both root and user, starting x and trying to control brightness to no avail

My file permissions for backlight.sh
-rwxr-xr-x

and other action scripts copied from the wiki are for brightness control:
-rwxr--r--
Back to top
View user's profile Send private message
OneNoteMan
n00b
n00b


Joined: 28 Sep 2018
Posts: 11

PostPosted: Sat Sep 29, 2018 2:40 pm    Post subject: Reply with quote

also tried a different wm incase there was something going on with xmonad

still no brightness control
Back to top
View user's profile Send private message
Anon-E-moose
Advocate
Advocate


Joined: 23 May 2008
Posts: 3485
Location: Dallas area

PostPosted: Sat Sep 29, 2018 2:49 pm    Post subject: Reply with quote

what does "cat /sys/class/backlight/intel_backlight/brightness" return?

and what does "cat /sys/class/backlight/intel_backlight/max_brightness" return?

And are you trying to run the shell script as root?
_________________
Asus m5a99fx, FX 8320 - nouveau & radeon, oss4
Acer laptop E5-575, i3-7100u - i965, alsa
---both---
4.14.62 kernel, profile 17.0 (no-pie) amd64-no-multilib
gcc 7.3.0, eudev, openrc, openbox, palemoon
Back to top
View user's profile Send private message
OneNoteMan
n00b
n00b


Joined: 28 Sep 2018
Posts: 11

PostPosted: Sat Sep 29, 2018 3:59 pm    Post subject: Reply with quote

both return just the number 4437

I can only run the scripts as root, the user cannot run it
but even still I cant get the brightness to change as root or user.

I noticed that my power button led is now lighting up for some reason even though i did not change anything

I tried running the scripts in my /etc/acpi/actions
i ran as root
FnHome-brightnessup.sh
this script actually returns a decreasing number, and outputs that number twice

FnHome-brightnessup.sh
this script actually returns a increasing number, and outputs that number twice

Also the changes are reflected in the file /sys/class/backlight/intel_backlight/brightness

so the actions scripts are changing the value of the brightness, but only when I manually run the command, and not when the key is pressed

interestingly when i run the script
powerbtn.sh
it actually shuts of my computer

I restarted again and the led for my power button is off again
Back to top
View user's profile Send private message
Anon-E-moose
Advocate
Advocate


Joined: 23 May 2008
Posts: 3485
Location: Dallas area

PostPosted: Sat Sep 29, 2018 4:09 pm    Post subject: Reply with quote

Ok run this command as root
Code:
echo 2000 >/sys/class/backlight/intel_backlight/brightness


does that change the brightness?
_________________
Asus m5a99fx, FX 8320 - nouveau & radeon, oss4
Acer laptop E5-575, i3-7100u - i965, alsa
---both---
4.14.62 kernel, profile 17.0 (no-pie) amd64-no-multilib
gcc 7.3.0, eudev, openrc, openbox, palemoon
Back to top
View user's profile Send private message
OneNoteMan
n00b
n00b


Joined: 28 Sep 2018
Posts: 11

PostPosted: Sat Sep 29, 2018 4:09 pm    Post subject: Reply with quote

I also realized something

I actually didnt do the portion from the wiki:
"...
By default some buttons are mapped to key codes that X can not handle or has no keysym for. So the following might be useful. It modifies the udev defaults slightly to fix the key combinations that otherwise would not work in X:
..."

the folder
/etc/udev/hwdb.d

did not exist is it necessary to make the folder and file?
Back to top
View user's profile Send private message
Anon-E-moose
Advocate
Advocate


Joined: 23 May 2008
Posts: 3485
Location: Dallas area

PostPosted: Sat Sep 29, 2018 4:16 pm    Post subject: Reply with quote

I don't think you need the folder

do this run acpi_listen and hit the fn+brightness up and down keys, and tell me what it returns.
_________________
Asus m5a99fx, FX 8320 - nouveau & radeon, oss4
Acer laptop E5-575, i3-7100u - i965, alsa
---both---
4.14.62 kernel, profile 17.0 (no-pie) amd64-no-multilib
gcc 7.3.0, eudev, openrc, openbox, palemoon
Back to top
View user's profile Send private message
josephg
l33t
l33t


Joined: 10 Jan 2016
Posts: 777
Location: usually offline

PostPosted: Sat Sep 29, 2018 4:18 pm    Post subject: Reply with quote

OneNoteMan wrote:
I tried to redo the instructions:
https://wiki.gentoo.org/wiki/ACPI/ThinkPad-special-buttons

I tried logging in as both root and user, starting x and trying to control brightness to no avail

My file permissions for backlight.sh
-rwxr-xr-x

and other action scripts copied from the wiki are for brightness control:
-rwxr--r--

I see no backlight.sh in that wiki page. Did you copy it from somewhere else?
_________________
"Growth for the sake of growth is the ideology of the cancer cell." Edward Abbey
Back to top
View user's profile Send private message
Anon-E-moose
Advocate
Advocate


Joined: 23 May 2008
Posts: 3485
Location: Dallas area

PostPosted: Sat Sep 29, 2018 4:22 pm    Post subject: Reply with quote

josephg wrote:

I see no backlight.sh in that wiki page. Did you copy it from somewhere else?


I had modified the default.sh script for acpi, and khayyam (very nicely) created the backlight.sh script from that. It gets talked about in the earlier link I provided.
_________________
Asus m5a99fx, FX 8320 - nouveau & radeon, oss4
Acer laptop E5-575, i3-7100u - i965, alsa
---both---
4.14.62 kernel, profile 17.0 (no-pie) amd64-no-multilib
gcc 7.3.0, eudev, openrc, openbox, palemoon
Back to top
View user's profile Send private message
OneNoteMan
n00b
n00b


Joined: 28 Sep 2018
Posts: 11

PostPosted: Sat Sep 29, 2018 4:28 pm    Post subject: Reply with quote

so I did the following and now it works.

firstly it seems no modification is required to /etc/acpi/default.sh so I did not need the info from:
https://forums.gentoo.org/viewtopic-t-1085854-highlight-.html

I also still did not make the change specified in the wiki https://wiki.gentoo.org/wiki/ACPI/ThinkPad-special-buttons starting at the point where it says:
"...
By default some buttons are mapped to key codes that X can not handle or has no keysym for. So the following might be useful. It modifies the udev defaults slightly to fix the key combinations that otherwise would not work in X:..."
so these modifcations are unnecessary

I restarted acpid

I though it still wasnt working but surely something was happening because a decrements and increment were occurring when the script ran.

I rebooted by laptop. Still nothing.

I remegered acpid set it to default and did

dispatch-conf

and took the new (untouched) files from the reinstall and overwrite the old ones that I modified.

rebooted again.

now my keys combinations were registering fn+home and fn+end were changing the brightness level numerically but no changes appeared.

I manually changed the value of the brightness, in the brightness file using Anon-E-moose's suggested command:
echo 2000 >/sys/class/backlight/intel_backlight/brightness

and boom brightness dropped :)

I tried my fn key combos again and this time held if for an extended period, the brightness does go down but just slowly ..very slowly.

Everything works now, so hopefully the rest of the function keys should go smoothly
Back to top
View user's profile Send private message
Anon-E-moose
Advocate
Advocate


Joined: 23 May 2008
Posts: 3485
Location: Dallas area

PostPosted: Sat Sep 29, 2018 4:31 pm    Post subject: Reply with quote

So change the script increment value from 10 to something like 200 (both up and down)

I originally set it at 10 because in my case it goes from 0 - 100, in your case it goes from 0 - 4437, so 10 will take a long time to show anything.
_________________
Asus m5a99fx, FX 8320 - nouveau & radeon, oss4
Acer laptop E5-575, i3-7100u - i965, alsa
---both---
4.14.62 kernel, profile 17.0 (no-pie) amd64-no-multilib
gcc 7.3.0, eudev, openrc, openbox, palemoon
Back to top
View user's profile Send private message
josephg
l33t
l33t


Joined: 10 Jan 2016
Posts: 777
Location: usually offline

PostPosted: Sat Sep 29, 2018 4:37 pm    Post subject: Reply with quote

So it's working now but very slowly? Good. You need to experiment with the increment value to change brightness when you hit the Fn keys. It seems yours is in the 1000s. Once you find a value you're comfortable with, you need to update your acpi scripts with that value.
_________________
"Growth for the sake of growth is the ideology of the cancer cell." Edward Abbey
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum