Skip to content

Instantly share code, notes, and snippets.

@Terbau
Forked from JoveYu/lenovo-fn-q.sh
Last active January 6, 2023 13:24
Show Gist options
  • Save Terbau/f45e19a6a78010bc590e7266620458bf to your computer and use it in GitHub Desktop.
Save Terbau/f45e19a6a78010bc590e7266620458bf to your computer and use it in GitHub Desktop.
Linux Lenove Fn+Q Power Mode Script (Lenovo IdeaPad Flex 5 14ALC05)
#!/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.PFMM"
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_ECO' > /proc/acpi/call; cat /proc/acpi/call; printf '\n'"
notify-send "Power Mode" "Battery Saving "
;;
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_BALANCE'> /proc/acpi/call; cat /proc/acpi/call; printf '\n'"
notify-send "Power Mode" "Intelligent Cooling"
;;
esac
@Terbau
Copy link
Author

Terbau commented Jan 6, 2023

Changed instructions to work with Lenovo IdeaPad Flex 5 14ALC05. For instructions for other lenovo laptops, refer to its wiki page here https://wiki.archlinux.org/ and check out the section for power management.

Requirements:

  • acpi_call (remember to modprobe)

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