Skip to content

Instantly share code, notes, and snippets.

@JoveYu
Last active July 17, 2024 15:40
Show Gist options
  • Save JoveYu/7502a96214b877c2d8867f42754430ec to your computer and use it in GitHub Desktop.
Save JoveYu/7502a96214b877c2d8867f42754430ec to your computer and use it in GitHub Desktop.
Linux Lenovo Fn+Q Power Mode Script
#!/bin/bash
ACPI_BALANCE="\_SB.PCI0.LPC0.EC0.VPC0.DYTC 0x000FB001"
ACPI_POWER="\_SB.PCI0.LPC0.EC0.VPC0.DYTC 0x0012B001"
ACPI_ECO="\_SB.PCI0.LPC0.EC0.VPC0.DYTC 0x0013B001"
ACPI_MODE="\_SB.PCI0.LPC0.EC0.SPMO"
MODE=$(sudo sh -c "echo '$ACPI_MODE' > /proc/acpi/call; tr -d '\0' < /proc/acpi/call")
MODE=${MODE:2}
TARGET=$(((MODE+1)%3))
case $TARGET in
0)
sudo sh -c "echo '$ACPI_BALANCE'> /proc/acpi/call; cat /proc/acpi/call; printf '\n'"
notify-send "Power Mode" "Intelligent Cooling"
;;
1)
sudo sh -c "echo '$ACPI_POWER' > /proc/acpi/call; cat /proc/acpi/call; printf '\n'"
notify-send "Power Mode" "Extreme Performance"
;;
2)
sudo sh -c "echo '$ACPI_ECO' > /proc/acpi/call; cat /proc/acpi/call; printf '\n'"
notify-send "Power Mode" "Battery Saving "
;;
esac
@JoveYu
Copy link
Author

JoveYu commented Jun 30, 2022

bind shortcut key Fn+Q to this script. it need kernel module acpi_call to send command to acpi

tested for

  • Lenovo IdeaPad 5 15
  • Lenovo Xiaoxin Air 15

@art0rz
Copy link

art0rz commented Jul 5, 2022

Hmm, this isn't working for me.

/proc/acpi/call: No such file or directory

Edit: Ah, I think I'm missing a package.

@JoveYu
Copy link
Author

JoveYu commented Jul 6, 2022

/proc/acpi/call need a kernel module acpi_call, you can search and install this in your package manager and reboot.

@art0rz
Copy link

art0rz commented Jul 6, 2022

I did but I'm getting Error: AE_NOT_FOUND

@JoveYu
Copy link
Author

JoveYu commented Jul 6, 2022

the acpi command in script, is not for you device. what is your model, and if your device support Fn+Q on windows?

@art0rz
Copy link

art0rz commented Jul 6, 2022

Yeah, I have a Legion 5 Pro 82JQ00UNMH. Fn+Q works in Windows. I just realized that Fn+Q also works in Manjaro, but it doesn't switch to high performance mode (red LED on power button). Only low and normal.

@JoveYu
Copy link
Author

JoveYu commented Jul 6, 2022

I can't help you, this script tested for IdadPad series

@art0rz
Copy link

art0rz commented Jul 6, 2022

Ah. Thanks anyway!

@asukaminato0721
Copy link

It works for 21A2 ThinkBook 14 G3 ACL

@Jockey12
Copy link

Jockey12 commented Jan 18, 2024

bind shortcut key Fn+Q to this script. it need kernel module acpi_call to send command to acpi

How would you do that, also Fn+Q works but you just have to know what mode you are in. Tested on Ideapad 3 Gaming, debian 12

@Just-Knight
Copy link

It works for Lenovo Ideapad 3 15

@Just-Knight
Copy link

Just-Knight commented Jan 26, 2024

bind shortcut key Fn+Q to this script. it need kernel module acpi_call to send command to acpi

Would you suggest we add acpi to the user group of commands? As currently this app requires sudo password anytime we try to trigger/call in via the shortcut.
Or should we add this script to be executed without password for root?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment