johnfanv2 / LenovoLegionLinux

Driver and tools for controlling Lenovo Legion laptops in Linux including fan control and power mode.
https://github.com/johnfanv2/LenovoLegionLinux
GNU General Public License v2.0
1.45k stars 51 forks source link

Support Fn+R refresh rate toggle #67

Open st0nie opened 1 year ago

st0nie commented 1 year ago

now I use a script to toggle refresh rate

https://github.com/st0nie/refreshd

and acpid event file

event=1E3391A1-2C89- 000000e8 00000000
action=sudo -u ston HOME=/home/ston/ DIPLAY=":1" XDG_RUNTIME_DIR=/run/user/1000 QT_QPA_PLATFORM=wayland /home/ston/.local/bin/refreshed toggle

But there is a problem with this. any fn+letter key combination triggers this toggle. Is there a way to only use fn+q?

MrDuartePT commented 1 year ago

I also have the same issue I also create a script for more DE https://github.com/MrDuartePT/hyprland-dotfiles/blob/master/refresh-rate-fn-r.sh

MrDuartePT commented 1 year ago

dmesg output when pressing the key:

[Sat Jun 17 00:33:25 2023] legion_laptop: Event: legion type: 1;  acpi type: 1 (1=integer)
[Sat Jun 17 00:33:26 2023] legion_laptop: Event: legion type: 1;  acpi type: 1 (1=integer)
[Sat Jun 17 00:33:27 2023] legion_laptop: Event: legion type: 4;  acpi type: 1 (1=integer)
[Sat Jun 17 00:33:27 2023] legion_laptop: Event: legion type: 4;  acpi type: 1 (1=integer)
[Sat Jun 17 00:33:41 2023] legion_laptop: Event: legion type: 1;  acpi type: 1 (1=integer)
[Sat Jun 17 00:33:41 2023] legion_laptop: Event: legion type: 1;  acpi type: 1 (1=integer)
[Sat Jun 17 00:33:49 2023] legion_laptop: Event: legion type: 1;  acpi type: 1 (1=integer)
[Sat Jun 17 00:33:50 2023] legion_laptop: Event: legion type: 1;  acpi type: 1 (1=integer)
[Sat Jun 17 00:33:51 2023] legion_laptop: Event: legion type: 1;  acpi type: 1 (1=integer)
[Sat Jun 17 00:33:51 2023] legion_laptop: Event: legion type: 1;  acpi type: 1 (1=integer)
[Sat Jun 17 00:35:02 2023] legion_laptop: Event: legion type: 1;  acpi type: 1 (1=integer)
[Sat Jun 17 00:35:05 2023] legion_laptop: Event: legion type: 1;  acpi type: 1 (1=integer)
[Sat Jun 17 00:35:05 2023] legion_laptop: Event: legion type: 1;  acpi type: 1 (1=integer)
[Sat Jun 17 00:35:06 2023] legion_laptop: Event: legion type: 1;  acpi type: 1 (1=integer)
[Sat Jun 17 00:35:06 2023] legion_laptop: Event: legion type: 1;  acpi type: 1 (1=integer)
[Sat Jun 17 00:35:07 2023] legion_laptop: Event: legion type: 1;  acpi type: 1 (1=integer)
[Sat Jun 17 00:35:15 2023] legion_laptop: Event: legion type: 1;  acpi type: 1 (1=integer)
[Sat Jun 17 00:35:15 2023] legion_laptop: Event: legion type: 1;  acpi type: 1 (1=integer)
[Sat Jun 17 00:35:16 2023] legion_laptop: Event: legion type: 1;  acpi type: 1 (1=integer)
[Sat Jun 17 00:36:23 2023] legion_laptop: Event: legion type: 1;  acpi type: 1 (1=integer)
[Sat Jun 17 00:36:29 2023] legion_laptop: Event: legion type: 1;  acpi type: 1 (1=integer)
[Sat Jun 17 00:36:31 2023] legion_laptop: Event: legion type: 1;  acpi type: 1 (1=integer)

acpi_listen:

 1E3391A1-2C89- 000000e8 00000000
 8FC0DE0C-B4E4- 000000d0 00000000
 1E3391A1-2C89- 000000e8 00000000
 8FC0DE0C-B4E4- 000000d0 00000000
 1E3391A1-2C89- 000000e8 00000000
 8FC0DE0C-B4E4- 000000d0 00000000
 1E3391A1-2C89- 000000e8 00000000
 8FC0DE0C-B4E4- 000000d0 00000000
 1E3391A1-2C89- 000000e8 00000000
 8FC0DE0C-B4E4- 000000d0 00000000
 1E3391A1-2C89- 000000e8 00000000
 8FC0DE0C-B4E4- 000000d0 00000000
 1E3391A1-2C89- 000000e8 00000000
 8FC0DE0C-B4E4- 000000d0 00000000
 1E3391A1-2C89- 000000e8 00000000
 8FC0DE0C-B4E4- 000000d0 00000000
 1E3391A1-2C89- 000000e8 00000000
 8FC0DE0C-B4E4- 000000d0 00000000
 1E3391A1-2C89- 000000e8 00000000

Also evtest dosent detect keypress:

Not running as root, no devices may be available.
Available devices:
/dev/input/event0:  Power Button
/dev/input/event1:  Lid Switch
/dev/input/event10: HD-Audio Generic Mic
/dev/input/event11: Razer Razer Basilisk
/dev/input/event12: Razer Razer Basilisk
/dev/input/event14: Ideapad extra buttons
/dev/input/event15: PC Speaker
/dev/input/event16: HDA NVidia HDMI/DP,pcm=3
/dev/input/event17: HDA NVidia HDMI/DP,pcm=7
/dev/input/event18: HDA NVidia HDMI/DP,pcm=8
/dev/input/event19: HDA NVidia HDMI/DP,pcm=9
/dev/input/event2:  Power Button
/dev/input/event20: HD-Audio Generic Headphone
/dev/input/event21: Razer Razer Basilisk
/dev/input/event3:  AT Raw Set 2 keyboard
/dev/input/event4:  Video Bus
/dev/input/event5:  Video Bus
/dev/input/event6:  ITE Tech. Inc. ITE Device(8910) Keyboard
/dev/input/event7:  MSFT0001:00 04F3:31DD Mouse
/dev/input/event8:  ITE Tech. Inc. ITE Device(8910) Wireless Radio Control
/dev/input/event9:  MSFT0001:00 04F3:31DD Touchpad
Select the device event number [0-21]: 14
Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x0 product 0x0 version 0x0
Input device name: "Ideapad extra buttons"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 1 (KEY_ESC)
    Event code 138 (KEY_HELP)
    Event code 148 (KEY_PROG1)
    Event code 149 (KEY_PROG2)
    Event code 186 (KEY_F16)
    Event code 190 (KEY_F20)
    Event code 192 (KEY_F22)
    Event code 193 (KEY_F23)
    Event code 202 (KEY_PROG3)
    Event code 203 (KEY_PROG4)
    Event code 212 (KEY_CAMERA)
    Event code 227 (KEY_SWITCHVIDEOMODE)
    Event code 240 (KEY_UNKNOWN)
    Event code 247 (KEY_RFKILL)
    Event code 364 (KEY_FAVORITES)
    Event code 431 (KEY_DISPLAYTOGGLE)
  Event type 4 (EV_MSC)
    Event code 4 (MSC_SCAN)
Properties:
Testing ... (interrupt to exit)
MrDuartePT commented 1 year ago

@st0nie you can discuss your ideias here. The special function keys will be introduce later.

darthf1 commented 3 months ago

Am I correct that this will be resolved with the linux kernel 6.9? It mentions IdeaPad specifically, but?

https://www.omgubuntu.co.uk/2024/05/linux-kernel-6-9-features

There’s also support for the Lenovo IdeaPad ‘refresh rate’ key (which you’ll be shocked to hear us used to change display refresh rate); fan speed control for Microsoft Surface laptops, and the Lenovo ThinkPad ACPI driver now works with more Fn keys.

MrDuartePT commented 3 months ago

Am I correct that this will be resolved with the linux kernel 6.9? It mentions IdeaPad specifically, but?

https://www.omgubuntu.co.uk/2024/05/linux-kernel-6-9-features

There’s also support for the Lenovo IdeaPad ‘refresh rate’ key (which you’ll be shocked to hear us used to change display refresh rate); fan speed control for Microsoft Surface laptops, and the Lenovo ThinkPad ACPI driver now works with more Fn keys.

Well I have kernel 6.9 install, I could test it. But if dosen't work I also planning on creating a patch to add fn+star (legion star symbol) and fn+PrtSC buttons

@st0nie well when I have time I can try to add Refresh Rate control to legiond

MrDuartePT commented 3 months ago

@st0nie @darthf1 dosent work on my model, the key is not recognised:

Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x0 product 0x0 version 0x0
Input device name: "Ideapad extra buttons"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 1 (KEY_ESC)
    Event code 138 (KEY_HELP)
    Event code 148 (KEY_PROG1)
    Event code 149 (KEY_PROG2)
    Event code 186 (KEY_F16)
    Event code 190 (KEY_F20)
    Event code 192 (KEY_F22)
    Event code 193 (KEY_F23)
    Event code 202 (KEY_PROG3)
    Event code 203 (KEY_PROG4)
    Event code 212 (KEY_CAMERA)
    Event code 227 (KEY_SWITCHVIDEOMODE)
    Event code 240 (KEY_UNKNOWN)
    Event code 247 (KEY_RFKILL)
    Event code 364 (KEY_FAVORITES)
    Event code 445 (?)
    Event code 446 (?)
    Event code 562 (?)
    Event code 634 (?)
  Event type 4 (EV_MSC)
    Event code 4 (MSC_SCAN)
darthf1 commented 3 months ago

@st0nie @darthf1 dosent work on my model, the key is not recognised:

Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x0 product 0x0 version 0x0
Input device name: "Ideapad extra buttons"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 1 (KEY_ESC)
    Event code 138 (KEY_HELP)
    Event code 148 (KEY_PROG1)
    Event code 149 (KEY_PROG2)
    Event code 186 (KEY_F16)
    Event code 190 (KEY_F20)
    Event code 192 (KEY_F22)
    Event code 193 (KEY_F23)
    Event code 202 (KEY_PROG3)
    Event code 203 (KEY_PROG4)
    Event code 212 (KEY_CAMERA)
    Event code 227 (KEY_SWITCHVIDEOMODE)
    Event code 240 (KEY_UNKNOWN)
    Event code 247 (KEY_RFKILL)
    Event code 364 (KEY_FAVORITES)
    Event code 445 (?)
    Event code 446 (?)
    Event code 562 (?)
    Event code 634 (?)
  Event type 4 (EV_MSC)
    Event code 4 (MSC_SCAN)

Too bad, thanks for checking!