### Example Error Message: Build Directory Not Found Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md An example of a build error indicating that kernel headers are not installed correctly for the current kernel. ```text make[1]: *** /lib/modules/6.2.9-arch1-1/build: No such file or directory. Stop. make[1]: Leaving directory '/home/user/LenovoLegionLinux/kernel_module' make: *** [Makefile:13: all] Error 2 ``` -------------------------------- ### Clone Repository and Install Dependencies Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README_LENOVO_LEGION_5.md Clones the LenovoLegionLinux repository and installs project-specific system dependencies using the provided script. This prepares the environment for further setup. ```bash cd ~/Downloads git clone https://github.com/johnfanv2/LenovoLegionLinux.git cd LenovoLegionLinux sudo ./deploy/dependencies/install_dependencies_ubuntu_22_04.sh ``` -------------------------------- ### Install and Run psensor for Monitoring Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md Install psensor to monitor temperatures and fan speeds. Run the command to launch the application. ```bash psensor ``` -------------------------------- ### Power Profiles CLI Example Output Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md Example output showing different power profiles like 'performance', 'balanced', and 'power-saver' with their drivers. ```text # performance: # Driver: platform_profile # Degraded: no # balanced: # Driver: platform_profile # * power-saver: # Driver: platform_profile ``` -------------------------------- ### Example Temperature Monitoring Output Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README_LENOVO_LEGION_5.md This is an example output from a temperature monitoring command, showing fan speeds and temperatures for CPU, GPU, and IC. ```text legion_hwmon-isa-0000 Adapter: ISA adapter Fan 1: 3100 RPM (max = 10000 RPM) Fan 2: 3100 RPM (max = 10000 RPM) CPU Temperature: +68.0°C GPU Temperature: +49.0°C IC Temperature: +80.0°C ``` -------------------------------- ### Build and Install Python Packages Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README_LENOVO_LEGION_5.md Builds and installs the Python packages for the legion_linux project within its virtual environment. This step is typically automated during the setup process. ```bash cd python/legion_linux ~/Downloads/LenovoLegionLinux/.venv/bin/python -m build --wheel --no-isolation sudo ~/Downloads/LenovoLegionLinux/.venv/bin/python -m installer ~/Downloads/LenovoLegionLinux/python/legion_linux/dist/*.whl ``` -------------------------------- ### Install ACPI Tools Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/doc/REVERSE_ENGINEER.md Installs the `acpica-tools` package, which provides utilities for working with ACPI tables. ```bash sudo apt install acpica-tools ``` -------------------------------- ### Install System Dependencies (Ubuntu 22.04) Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README_LENOVO_LEGION_5.md Installs necessary packages for building and running the LenovoLegionLinux project on Ubuntu 22.04. Ensure your system is updated before proceeding. ```bash sudo apt update && sudo apt upgrade -y sudo apt install -y make gcc linux-headers-$(uname -r) build-essential git lm-sensors wget dkms stress-ng sudo apt install -y python3-venv python3-pip python3-dev python3-setuptools python3-wheel ``` -------------------------------- ### Enable Flip to Start Feature Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/doc/FEATURES_AND_TESTING.md Enables the 'Flip to Start' feature by modifying the corresponding UEFI variable. Requires root privileges and temporarily removes write protection. ```bash sudo chattr -i /sys/firmware/efi/efivars/FBSWIF-d743491e-f484-4952-a87d-8d5dd189b70c # first 4 bytes are attributes printf '\x07\x00\x00\x00\x01\x00\x00\x00' | sudo tee /sys/firmware/efi/efivars/FBSWIF-d743491e-f484-4952-a87d-8d5dd189b70c cat /sys/firmware/efi/efivars/FBSWIF-d743491e-f484-4952-a87d-8d5dd189b70c | hexdump -C ``` -------------------------------- ### Install Dependencies on openSUSE Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md Installs necessary packages for the tool on openSUSE systems. Covers build tools, kernel development files, sensors, and Python dependencies. ```bash sudo zypper install make gcc kernel-devel kernel-default-devel git libopenssl-devel sensors dmidecode python3-qt5 python3-pip python3-PyYAML python3-argcomplete python3-darkdetect # Install the following for installation with DKMS sudo zypper install dkms openssl mokutil ``` -------------------------------- ### Install DKMS Prerequisites Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md Installs necessary packages for building the kernel module with DKMS on Arch-based systems. ```bash sudo pacman -S dkms openssl mokutil ``` -------------------------------- ### Install Power Profiles Daemon Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md To enable graphical power mode switching in desktop environments like GNOME or KDE, install the `power-profiles-daemon` service. This service integrates with system tools to manage power settings. ```bash sudo apt install power-profiles-daemon ``` -------------------------------- ### Install RyzenAdj for Powerstate Inspection Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/doc/FEATURES_AND_TESTING.md Installs necessary development headers, clones the RyzenAdj repository, and builds the tool for powerstate inspection on AMD systems. This is a multi-step process requiring git and cmake. ```bash sudo apt install libpci-dev git clone https://github.com/FlyGoat/RyzenAdj.git cd RyzenAdj mkdir build && cd build cmake -DCMAKE_BUILD_TYPE=Release .. make ``` -------------------------------- ### Install Dependencies on Ubuntu/Debian Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md Installs necessary packages for building and running the Lenovo Legion Linux tool on Ubuntu-based systems. Includes packages for development, sensors, and Python utilities. ```bash sudo apt-get update sudo apt-get install -y make gcc linux-headers-$(uname -r) build-essential git lm-sensors wget python3-pyqt6 python3-yaml python3-venv python3-pip python3-argcomplete python3-darkdetect # Install the following for installation with DKMS sudo apt-get install dkms openssl mokutil ``` -------------------------------- ### Install Dependencies on RHEL/CentOS/Fedora Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md Installs required packages for building and running the tool on RHEL-based systems using dnf. Includes development tools, kernel headers, and Python libraries. ```bash sudo dnf install -y kernel-headers kernel-devel dmidecode lm_sensors python3-PyQt6 python3-yaml python3-pip python3-argcomplete python3-darkdetect sudo dnf groupinstall "Development Tools" sudo dnf group install "C Development Tools and Libraries" # Install the following for installation with DKMS sudo dnf install dkms openssl mokutil ``` -------------------------------- ### Install Kernel Module via DKMS (Makefile) Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md Installs the kernel module using DKMS via the provided Makefile. Requires root privileges. ```bash cd kernel_module sudo make dkms ``` -------------------------------- ### Enable and Start Legiond Services Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/extra/service/legiond/README.org Enables and starts the legiond service, the legiond-onresume service, and the legiond-cpuset timer. This ensures legiond runs automatically on boot and handles resume events and CPU set operations. ```shell systemctl enable --now legiond.service legiond-onresume.service legiond-cpuset.timer ``` -------------------------------- ### Get Help with CLI Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README_LENOVO_LEGION_5.md Display help information for the legion_cli tool to understand available commands and options. ```bash ~/Downloads/LenovoLegionLinux/.venv/bin/legion_cli --help ``` -------------------------------- ### Compile and Install Kernel Module Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README_LENOVO_LEGION_5.md Compiles the kernel module and installs it using DKMS for permanent integration. It also configures the module to load automatically on boot. ```bash cd kernel_module make clean && make sudo make dkms echo "legion_laptop" | sudo tee -a /etc/modules ``` -------------------------------- ### Install Dependencies on Arch/Manjaro Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md Installs required packages for building and running the tool on Arch Linux and its derivatives. Includes kernel headers, development tools, and Python libraries. ```bash sudo pacman -S linux-headers base-devel lm_sensors git dmidecode python-pyqt6 python-yaml python-argcomplete python-darkdetect ``` -------------------------------- ### Permanent Kernel Module Installation Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md Installs the kernel module permanently after successful building and testing. This command should be run from the kernel_module directory. ```bash make sudo make install ``` -------------------------------- ### Start Python GUI for Fan Curve Control Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md Run the Python GUI as root from the LenovoLegionLinux folder to change and set custom fan curves. ```bash # run from folder LenovoLegionLinux sudo python/legion_linux/legion_linux/legion_gui.py ``` -------------------------------- ### Read Flip to Start UEFI Variable Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/doc/FEATURES_AND_TESTING.md Reads the current value of the Flip to Start UEFI variable. This variable controls the 'Flip to Start' feature. ```bash cat /sys/firmware/efi/efivars/FBSWIF-d743491e-f484-4952-a87d-8d5dd189b70c | hexdump -C ``` -------------------------------- ### Install FWTS for WMI Inspection Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/doc/REVERSE_ENGINEER.md Installs the Firmware Test Suite (FWTS) required for inspecting WMI entries. This is a prerequisite for the `fwts wmi` command. ```bash sudo apt install fwts ``` -------------------------------- ### Install Kernel Module via DKMS (Manual Copy) Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md Manually copies the module files to the DKMS source directory and adds the module to DKMS. ```bash sudo mkdir -p /usr/src/LenovoLegionLinux-1.0.0 sudo cp ./kernel_module/* /usr/src/LenovoLegionLinux-1.0.0 -r sudo dkms add -m LenovoLegionLinux -v 1.0.0 sudo dkms build -m LenovoLegionLinux -v 1.0.0 ``` -------------------------------- ### Lighting Methods Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/doc/FEATURES_AND_TESTING.md Provides methods for controlling Lenovo lighting features, including getting and setting the current status and brightness. ```APIDOC ## Get_Lighting_Current_Status ### Description Get Current Lighting Status. ### Method Not specified (WMI Method) ### Endpoint Not specified ### Parameters #### Path Parameters - **lighting_id** (string) - Required - Identifier for the lighting setting. ### Request Example Not specified ### Response #### Success Response - **current_Brigness_Level** (string) - Description of current brightness level. - **Current_State_Type** (string) - Description of current state type. ### Response Example Not specified ## Set_Lighting_Current_Status ### Description Set Current Lighting Status. ### Method Not specified (WMI Method) ### Endpoint Not specified ### Parameters #### Path Parameters - **Lighting_ID** (string) - Required - Identifier for the lighting setting. #### Request Body - **Current_Brithngess_Level** (string) - Required - The desired brightness level. - **Current_State_Type** (string) - Required - The desired state type. ### Request Example Not specified ### Response Not specified ``` -------------------------------- ### Start Python CLI for Fan Curve Control Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md Execute the Python CLI from the LenovoLegionLinux folder to manage fan curves via command line arguments. ```bash # run from folder LenovoLegionLinux sudo python/legion_linux/legion_linux/legion_cli.py ``` -------------------------------- ### Example Fan Curve Data Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md This is an example of the expected output when reading the fan curve. It includes chip information, fan curve points size, and a detailed table of fan curve settings. ```text EC Chip ID: 8227 EC Chip Version: 2a4 fan curve current point id: 0 fan curve points size: 8 Current fan curve in UEFI u(speed_of_unit)|speed1[u]|speed2[u]|speed1[pwm]|speed2[pwm]|acceleration|deceleration|cpu_min_temp|cpu_max_temp|gpu_min_temp|gpu_max_temp|ic_min_temp|ic_max_temp 3 0 0 0 0 3 3 0 50 0 50 0 30 3 11 11 28 28 3 3 50 55 50 55 30 40 3 13 13 33 33 3 3 55 60 55 60 40 50 3 20 20 51 51 3 3 60 65 60 65 50 55 3 22 22 56 56 3 3 65 70 65 70 55 127 3 24 24 61 61 3 3 70 75 70 75 127 127 3 28 28 71 71 2 2 75 80 75 80 127 127 3 33 33 84 84 2 2 80 88 80 88 127 127 3 40 40 102 102 2 2 88 90 88 90 127 127 3 44 44 112 112 2 2 90 127 90 127 127 127 ``` -------------------------------- ### Monitor System with CLI Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README_LENOVO_LEGION_5.md Use the legion_cli monitor command to check system status at a specified interval. Requires the legion_cli tool to be installed in a virtual environment. ```bash ~/Downloads/LenovoLegionLinux/.venv/bin/legion_cli monitor 5 ``` -------------------------------- ### Disable Flip to Start Feature Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/doc/FEATURES_AND_TESTING.md Disables the 'Flip to Start' feature by modifying the corresponding UEFI variable. Requires root privileges and temporarily removes write protection. ```bash sudo chattr -i /sys/firmware/efi/efivars/FBSWIF-d743491e-f484-4952-a87d-8d5dd189b70c # first 4 bytes are attributes printf '\x07\x00\x00\x00\x00\x00\x00\x00' | sudo tee /sys/firmware/efi/efivars/FBSWIF-d743491e-f484-4952-a87d-8d5dd189b70c cat /sys/firmware/efi/efivars/FBSWIF-d743491e-f484-4952-a87d-8d5dd189b70c | hexdump -C ``` -------------------------------- ### Disassemble ACPI Tables Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/doc/REVERSE_ENGINEER.md Creates a directory, copies ACPI tables (specifically those starting with 'SDT'), and then uses `iasl` to disassemble them into a DSDT.dsl file. This process requires root privileges for copying files. ```bash mkdir acpi_re cd acpi_re ls /sys/firmware/acpi/tables/ sudo cp --no-preserve=mode /sys/firmware/acpi/tables/*SDT* . iasl -e SSDT* -d DSDT ``` -------------------------------- ### Control Keyboard Backlight via IO-Port Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/doc/FEATURES_AND_TESTING.md Controls the keyboard backlight using IO-port access, likely for specific hardware implementations. This snippet shows how to get the current state and set it to on or off. ```bash # Get current state echo '\_SB.GZFD.WMBA 0 0x1 0x5' > /proc/acpi/call cat /proc/acpi/call; printf '\n' {0x00, 0x01} # Set current state (off?) echo '\_SB.GZFD.WMBA 0 0x2 {0x05, 0x00, 0x01}' > /proc/acpi/call cat /proc/acpi/call; printf '\n' # Set current state (on?) echo '\_SB.GZFD.WMBA 0 0x2 {0x05, 0x01, 0x02}' > /proc/acpi/call cat /proc/acpi/call; printf '\n' ``` -------------------------------- ### Gather Lenovo WMI Info in Windows Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/doc/REVERSE_ENGINEER.md A PowerShell script to list all available Lenovo-specific WMI classes and their methods. It outputs detailed information about each WMI class, including its name, GUID, and methods. ```powershell $wmi_classes = Get-WmiObject -Namespace 'ROOT/WMI' -List -Class "*LENOVO*" foreach ($wmi_class in $wmi_classes){ Write-Host "########################################" Write-Host "########################################" Write-Host "########################################" Write-Host "Name:" $wmi_class.Name Write-Host "Class Name:" $wmi_class.Name Write-Host "Class GUID:" $wmi_class.Qualifiers["guid"].Value Write-Host "Description:" $wmi_class.Methods.Count Write-Host "Methods:" foreach ($method in $wmi_class.Methods){ Write-Host "Name:" $method.Name Write-Host "WmiMethodId:" $method.Qualifiers["WmiMethodId"].Value Write-Host "Class Name:" $wmi_class.Name Write-Host "Class GUID:" $wmi_class.Qualifiers["guid"].Value Write-Host "Description:" $method.Qualifiers["Description"].Value Write-Host "Implemented:" $method.Qualifiers["Implemented"].Value Write-Host "" } Write-Host "" } ``` -------------------------------- ### Quick Test: Reload Module Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md Reloads the kernel module to check if it is properly loaded after installation (for non-DKMS). ```bash sudo make reloadmodule ``` -------------------------------- ### Install via DKMS for Automatic Kernel Updates Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md Using DKMS (Dynamic Kernel Module Support) automates the process of recompiling and reinstalling the Lenovo Legion Linux kernel module after each kernel update, ensuring continuous functionality. ```bash sudo apt install dkms dkms autoinstall ``` -------------------------------- ### Build and Test Kernel Module Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md Clones the repository, navigates to the kernel module directory, builds the module, and reloads it for testing. ```bash git clone https://github.com/johnfanv2/LenovoLegionLinux.git cd LenovoLegionLinux/kernel_module make sudo make reloadmodule ``` -------------------------------- ### Legion CLI Usage Help Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md Displays help information and available subcommands for the Legion CLI tool. ```text usage: legion_cli.py [-h] {fancurve-write-preset-to-hw,fancurve-write-hw-to-preset,fancurve-write-file-to-hw,fancurve-write-hw-to-file} ... Legion CLI options: -h, --help show this help message and exit subcommands: {fancurve-write-preset-to-hw,fancurve-write-hw-to-preset,fancurve-write-file-to-hw,fancurve-write-hw-to-file} fancurve-write-preset-to-hw Write fan curve from preset to hardware fancurve-write-hw-to-preset Write fan curve from hardware to preset fancurve-write-file-to-hw Write fan curve from file to hardware fancurve-write-hw-to-file Write fan curve from hardware to file ``` -------------------------------- ### Inspect WMI Entries with FWTS Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/doc/REVERSE_ENGINEER.md Creates a directory, navigates into it, and then uses `fwts wmi` to capture WMI information to a log file. This command requires root privileges. ```bash mkdir fwts_re cd fwts_re sudo fwts wmi - > fwts_wmi.log ``` -------------------------------- ### Check CPU Power Limits with ryzenadj Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md Observe changes in CPU power limits by using `ryzenadj` after changing the power mode with Fn+Q. This helps in analyzing ACPI firmware behavior. ```bash ryzenadj ``` -------------------------------- ### Set Power Profile using powerprofilesctl Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md Use the powerprofilesctl command to set the system's power profile. Available profiles include power-saver, balanced, and performance. ```bash # Set a profile, e.g. power-saver=quiet powerprofilesctl set power-saver # or balanced powerprofilesctl set balanced # or performance powerprofilesctl set performance ``` -------------------------------- ### Enable CPU Boost Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/doc/FEATURES_AND_TESTING.md Enables the CPU boost functionality by writing '1' to the system's boost control file. This can improve performance at the cost of increased power usage. ```bash sudo sh -c "echo '1' > /sys/devices/system/cpu/cpufreq/boost" ``` -------------------------------- ### Troubleshoot Permission Errors Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README_LENOVO_LEGION_5.md Command to set appropriate read/write permissions for system files related to fan control and hardware monitoring. Use with caution. ```bash sudo chmod 644 /sys/module/legion_laptop/drivers/platform:legion/PNP0C09:00/* ``` -------------------------------- ### Troubleshoot Module Loading Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README_LENOVO_LEGION_5.md Commands to check if the legion-laptop module is loaded, view kernel messages for errors, and manually reload the module. ```bash lsmod | grep legion ``` ```bash sudo dmesg | grep -i legion ``` ```bash sudo rmmod legion-laptop sudo modprobe legion_laptop ``` -------------------------------- ### Monitor ACPI Events for Fn-Lock Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/doc/FEATURES_AND_TESTING.md Listens for ACPI events generated by hardware key presses, such as Fn-Lock toggles or Fn+Q combinations. Requires the 'acpid' package to be installed. ```bash sudo apt-get install acpid acpi_listen # When pressing Fn-Lock # 8FC0DE0C-B4E4- 000000d0 00000000 # 1E3391A1-2C89- 000000e8 00000000 # When pressing Fn+Q (power switch) # D320289E-8FEA- 000000e3 00000000 # D320289E-8FEA- 000000e7 00000000 ``` -------------------------------- ### Panel Methods Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/doc/FEATURES_AND_TESTING.md Provides methods for interacting with the Lenovo Legion panel features, including game aid timers, display modes, gamut switching, and MPRT settings. ```APIDOC ## Panel_Set_Game_Aid_Timer_Info ### Description Set Panel Game Aid Timer Info. ### Method Not specified (WMI Method) ### Endpoint Not specified ### Parameters Not specified ### Request Example Not specified ### Response Not specified ## Panel_Get_Game_Aid_Countdown_Info ### Description Get Panel Game Aid Countdown Timer Info. ### Method Not specified (WMI Method) ### Endpoint Not specified ### Parameters Not specified ### Request Example Not specified ### Response Not specified ## Panel_Set_Game_Aid_Countdown_Info ### Description Set Panel Game Aid Countdown Timer Info. ### Method Not specified (WMI Method) ### Endpoint Not specified ### Parameters Not specified ### Request Example Not specified ### Response Not specified ## Panel_Get_Display_Mode ### Description Get Panel Display Mode. ### Method Not specified (WMI Method) ### Endpoint Not specified ### Parameters Not specified ### Request Example Not specified ### Response Not specified ## Panel_Set_Display_Mode ### Description Set Panel Display Mode. ### Method Not specified (WMI Method) ### Endpoint Not specified ### Parameters Not specified ### Request Example Not specified ### Response Not specified ## Panel_Get_Gamut_Switch ### Description Get Panel Gamut Switch. ### Method Not specified (WMI Method) ### Endpoint Not specified ### Parameters Not specified ### Request Example Not specified ### Response Not specified ## Panel_Set_Gamut_Switch ### Description Set Panel Gamut Switch. ### Method Not specified (WMI Method) ### Endpoint Not specified ### Parameters Not specified ### Request Example Not specified ### Response Not specified ## Panel_Get_MPRT ### Description Get Panel MPRT info. ### Method Not specified (WMI Method) ### Endpoint Not specified ### Parameters Not specified ### Request Example Not specified ### Response Not specified ## Panel_Set_MPRT ### Description Set Panel MPRT info. ### Method Not specified (WMI Method) ### Endpoint Not specified ### Parameters Not specified ### Request Example Not specified ### Response Not specified ``` -------------------------------- ### Recompile/Reinstall Kernel Module Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md If the Lenovo Legion Linux driver stops working after a kernel update, recompiling or reinstalling the module is a common solution. Refer to the permanent install instructions for details. ```bash sudo apt install --reinstall linux-headers-$(uname -r) build-essential make -C /lib/modules/$(uname -r)/build M=$(pwd) modules sudo make -C /lib/modules/$(uname -r)/build M=$(pwd) modules_install sudo modprobe lenovolegionlinux ``` -------------------------------- ### List Available Power Profiles Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md Display all available power profiles using the powerprofilesctl command. Power-saver is indicated by blue. ```bash # List all profiles (power-saver = quiet= blue) powerprofilesctl list ``` -------------------------------- ### Build and Run gpu-burn for NVIDIA GPU Stress Test Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/doc/FEATURES_AND_TESTING.md Builds the gpu-burn stress testing tool using Docker and then runs it, utilizing all available NVIDIA GPUs. This is useful for testing GPU stability and thermal performance. ```bash git clone https://github.com/wilicc/gpu-burn cd gpu-burn docker build -t gpu_burn . docker run --rm --gpus all gpu_burn ``` -------------------------------- ### Modify Power Mode via CLI Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md If a graphical interface is not available or preferred, power modes can be adjusted using command-line tools. This is a fallback option before installing system services like `power-profiles-daemon`. ```bash sudo legion-config power-mode ``` -------------------------------- ### Enable Custom Power Mode Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md Enter the custom power mode, which may change the LED to pink/purple and allow customization of CPU/GPU boost and TGP settings. This mode is accessible via GUI or command line. ```bash echo balanced-performance > /sys/firmware/acpi/platform_profile ``` -------------------------------- ### Monitor GPU Power State Transition Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md Observe the GPU's power state after running nvidia-smi. It should transition from 'D0' to 'D3cold' after a period of inactivity. ```bash # Note: Only one of the commands would work; depending on the path to the device which is your GPU # It should output "D3cold": cat /sys/devices/pci0000:00/0000:00:01.0/power_state cat /sys/devices/pci0000:00/0000:00:01.1/power_state ``` -------------------------------- ### Control Fan Full Speed via ACPI Call Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/doc/FEATURES_AND_TESTING.md Interacts with the LENOVO_FAN_METHOD WMI class to get and set the fan's full speed status. Requires root privileges and knowledge of the specific WMI method IDs. ```bash # get full speed status echo '\_SB.GZFD.WMB2 0 0x1 0' > /proc/acpi/call cat /proc/acpi/call; printf '\n' # set to full speed echo '\_SB.GZFD.WMB2 0 0x2 1' > /proc/acpi/call cat /proc/acpi/call; printf '\n' ``` -------------------------------- ### Execute Fan Curve Script Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md Run the setmyfancurve.sh script from the LenovoLegionLinux folder to apply a custom fan curve. Ensure the script is executable. ```bash # Go to folder LenovoLegionLinux and run it. It should output "Writing fancurve successful!" if it finishes successful sudo ./setmyfancurve.sh ``` -------------------------------- ### Copy Configuration Files Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/extra/service/legiond/README.org Copies the default configuration files for legiond to the /etc/legion_linux/ directory. This is a prerequisite for modifying legiond's settings. ```shell sudo cp /usr/share/legion_linux/{*.yaml,legiond.ini} /etc/legion_linux/ ``` -------------------------------- ### Check X11 Session Type Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md Verify that your current session is using X11, which is required for certain GPU management configurations. ```bash # It should output something like: "x11" echo $XDG_SESSION_TYPE ``` -------------------------------- ### Recreate Python Virtual Environment Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README_LENOVO_LEGION_5.md Steps to recreate the Python virtual environment for the Lenovo Legion Linux project. This is useful for resolving environment-specific issues. ```bash cd ~/Downloads/LenovoLegionLinux python3 -m venv .venv source .venv/bin/activate pip install -r requirements.txt # if available ``` -------------------------------- ### LENOVO_CPU_METHOD Methods Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/doc/FEATURES_AND_TESTING.md Provides methods for controlling and querying CPU overclocking (OC) status and power limits. ```APIDOC ## CPU_Get_OC_Status ### Description Retrieves the CPU Overclocking (OC) status. ### Method N/A (WMI Method) ### Endpoint N/A (WMI Class GUID: {14afd777-106f-4c9b-b334-d388dc7809be}, WmiMethodId: 1) ### Parameters None ### Request Example None ### Response #### Success Response - N/A ### Response Example None ``` ```APIDOC ## CPU_Set_OC_Status ### Description Sets the CPU Overclocking (OC) status. ### Method N/A (WMI Method) ### Endpoint N/A (WMI Class GUID: {14afd777-106f-4c9b-b334-d388dc7809be}, WmiMethodId: 2) ### Parameters None ### Request Example None ### Response #### Success Response - N/A ### Response Example None ``` ```APIDOC ## CPU_Get_ShortTerm_PowerLimit ### Description Retrieves the CPU Short-Term Power Limit. ### Method N/A (WMI Method) ### Endpoint N/A (WMI Class GUID: {14afd777-106f-4c9b-b334-d388dc7809be}, WmiMethodId: 3) ### Parameters None ### Request Example None ### Response #### Success Response - buffer (object) - CPU Short-Term Power Limit data ### Response Example None ``` -------------------------------- ### Check CPU Frequency Information Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/doc/FEATURES_AND_TESTING.md Displays detailed information about the CPU's current frequency scaling settings and available governors. This is useful for performance tuning. ```bash cpupower frequency-info ``` -------------------------------- ### Display Sensor Values Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md Use the 'sensors' command to display current CPU and GPU temperatures, as well as fan speeds. This is useful for initial testing and monitoring system load effects. ```bash sensors ``` -------------------------------- ### Memory Methods Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/doc/FEATURES_AND_TESTING.md Provides methods for managing Lenovo memory overclocking (OC) settings, including status and data configuration. ```APIDOC ## MEM_Get_OC_Status ### Description Get Memory OC Status. ### Method Not specified (WMI Method) ### Endpoint Not specified ### Parameters Not specified ### Request Example Not specified ### Response Not specified ## MEM_Set_OC_Status ### Description Set Memory OC Status. ### Method Not specified (WMI Method) ### Endpoint Not specified ### Parameters Not specified ### Request Example Not specified ### Response Not specified ## MEM_Set_OC_Data ### Description Set Memory OC Data. ### Method Not specified (WMI Method) ### Endpoint Not specified ### Parameters Not specified ### Request Example Not specified ### Response Not specified ``` -------------------------------- ### Configure Legiond Service Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md Edit the legiond.ini configuration file to enable and customize CPU and GPU control settings for different power modes and power states (battery/AC). ```ini [legiond] cpu_control=true bat_bp=... # Custom Cpu setting for custom mode on battery ac_bp=... # Custom Cpu setting for custom mode on charger bat_q=... # Custom Cpu setting for quiet mode on battery ac_q=... # Custom Cpu setting for quiet mode on charger bat_b=... # Custom Cpu setting for balance mode on battery ac_b=... # Custom Cpu setting for balance mode on charger ac_p=... # Custom Cpu setting for performance mode on charger gpu_control=true nvidia=true radeon=false tdp_bat_bp=... # Custom GPU TDP for custom mode on battery tdp_ac_bp=... # Custom GPU TDP for custom mode on charger tdp_bat_q=... # Custom GPU TDP for quiet mode on battery tdp_ac_q=... # Custom GPU TDP for quiet mode on charger tdp_bat_b=... # Custom GPU TDP for balance mode on battery tdp_ac_b=... # Custom GPU TDP for balance mode on charger tdp_ac_p=... # Custom GPU TDP for performance mode on charger ``` -------------------------------- ### Fan Curve Control with CLI Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README_LENOVO_LEGION_5.md Write the current hardware fan curve to a file or load a custom fan curve from a file using legion_cli. Ensure the file paths are correct. ```bash ~/Downloads/LenovoLegionLinux/.venv/bin/legion_cli fancurve-write-hw-to-file /tmp/current_curve.txt ``` ```bash ~/Downloads/LenovoLegionLinux/.venv/bin/legion_cli fancurve-write-file-to-hw /tmp/custom_curve.txt ``` -------------------------------- ### Add Hardware Support for Legion Pro 5 16IRX9 Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README_LENOVO_LEGION_5.md Manually adds support for the Lenovo Legion Pro 5 16IRX9 (Model 83DF) to the kernel module by modifying the `legion-laptop.c` file. This is necessary as the model is not in the default allowlist. ```c { // e.g. Legion Pro 5 16IRX9 (83DF) .ident = "N0CN", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), DMI_MATCH(DMI_BIOS_VERSION, "N0CN"), }, .driver_data = (void *)&model_g8cn }, ``` -------------------------------- ### LENOVO_GAMEZONE_DATA Methods Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/doc/FEATURES_AND_TESTING.md Provides access to various gaming-related features including Over Drive status, lighting control, and thermal mode settings. ```APIDOC ## Get Gaming Product Info ### Description Retrieves gaming product information. ### Method N/A (WMI Method) ### Endpoint N/A (WMI Class GUID: {887B54E3-DDDC-4B2C-8B88-68A26A8835D0}) ### Parameters None ### Request Example None ### Response #### Success Response - data (object) - Gaming product information ### Response Example None ``` ```APIDOC ## IsSupportOD ### Description Checks if the Over Drive feature is supported. ### Method N/A (WMI Method) ### Endpoint N/A (WMI Class GUID: {887B54E3-DDDC-4B2C-8B88-68A26A8835D0}, WmiMethodId: 49) ### Parameters None ### Request Example None ### Response #### Success Response - data (object) - Indicates support status ### Response Example None ``` ```APIDOC ## GetODStatus ### Description Retrieves the current status of the Over Drive feature. ### Method N/A (WMI Method) ### Endpoint N/A (WMI Class GUID: {887B54E3-DDDC-4B2C-8B88-68A26A8835D0}, WmiMethodId: 50) ### Parameters None ### Request Example None ### Response #### Success Response - data (object) - Current Over Drive status ### Response Example None ``` ```APIDOC ## SetODStatus ### Description Sets the status of the Over Drive feature. ### Method N/A (WMI Method) ### Endpoint N/A (WMI Class GUID: {887B54E3-DDDC-4B2C-8B88-68A26A8835D0}, WmiMethodId: 51) ### Parameters #### Request Body - data (integer) - 0 or 1 to set the status ### Request Example None ### Response #### Success Response - nothing ### Response Example None ``` ```APIDOC ## SetLightControlOwner ### Description Sets the owner for light control. ### Method N/A (WMI Method) ### Endpoint N/A (WMI Class GUID: {887B54E3-DDDC-4B2C-8B88-68A26A8835D0}, WmiMethodId: 52) ### Parameters None ### Request Example None ### Response #### Success Response - N/A ### Response Example None ``` ```APIDOC ## SetDDSControlOwner ### Description Sets the owner for DDS control. ### Method N/A (WMI Method) ### Endpoint N/A (WMI Class GUID: {887B54E3-DDDC-4B2C-8B88-68A26A8835D0}, WmiMethodId: 53) ### Parameters None ### Request Example None ### Response #### Success Response - N/A ### Response Example None ``` ```APIDOC ## IsRestoreOCValue ### Description Checks if the OC value is set to restore. ### Method N/A (WMI Method) ### Endpoint N/A (WMI Class GUID: {887B54E3-DDDC-4B2C-8B88-68A26A8835D0}, WmiMethodId: 54) ### Parameters None ### Request Example None ### Response #### Success Response - N/A ### Response Example None ``` ```APIDOC ## GetThermalMode ### Description Retrieves the current thermal mode. ### Method N/A (WMI Method) ### Endpoint N/A (WMI Class GUID: {887B54E3-DDDC-4B2C-8B88-68A26A8835D0}, WmiMethodId: 55) ### Parameters None ### Request Example None ### Response #### Success Response - data (integer) - Thermal mode (1, 2, or 3) ### Response Example None ``` ```APIDOC ## GetBIOSOCMode ### Description Retrieves the OC switch status from BIOS. ### Method N/A (WMI Method) ### Endpoint N/A (WMI Class GUID: {887B54E3-DDDC-4B2C-8B88-68A26A8835D0}, WmiMethodId: 56) ### Parameters None ### Request Example None ### Response #### Success Response - N/A ### Response Example None ``` ```APIDOC ## SetIntelligentSubMode ### Description Sets the current mode within Intelligent Mode. ### Method N/A (WMI Method) ### Endpoint N/A (WMI Class GUID: {887B54E3-DDDC-4B2C-8B88-68A26A8835D0}, WmiMethodId: 57) ### Parameters None ### Request Example None ### Response #### Success Response - N/A ### Response Example None ``` ```APIDOC ## GetIntelligentSubMode ### Description Retrieves the current mode within Intelligent Mode. ### Method N/A (WMI Method) ### Endpoint N/A (WMI Class GUID: {887B54E3-DDDC-4B2C-8B88-68A26A8835D0}, WmiMethodId: 58) ### Parameters None ### Request Example None ### Response #### Success Response - N/A ### Response Example None ``` ```APIDOC ## GetHardwareInfoSupportVersion ### Description Retrieves the support version for hardware information. ### Method N/A (WMI Method) ### Endpoint N/A (WMI Class GUID: {887B54E3-DDDC-4B2C-8B88-68A26A8835D0}, WmiMethodId: 59) ### Parameters None ### Request Example None ### Response #### Success Response - N/A ### Response Example None ``` ```APIDOC ## GetCpuFrequency ### Description Retrieves the maximum frequency of CPU core 0. ### Method N/A (WMI Method) ### Endpoint N/A (WMI Class GUID: {887B54E3-DDDC-4B2C-8B88-68A26A8835D0}, WmiMethodId: 60) ### Parameters None ### Request Example None ### Response #### Success Response - data (object) - CPU core 0 max frequency ### Response Example None ``` ```APIDOC ## GetLearningProfileCount ### Description Retrieves the total count of Learning Profiles. ### Method N/A (WMI Method) ### Endpoint N/A (WMI Class GUID: {887B54E3-DDDC-4B2C-8B88-68A26A8835D0}, WmiMethodId: 61) ### Parameters None ### Request Example None ### Response #### Success Response - N/A ### Response Example None ``` ```APIDOC ## IsACFitForOC ### Description Checks if the adapter type is suitable for Overclocking (OC). ### Method N/A (WMI Method) ### Endpoint N/A (WMI Class GUID: {887B54E3-DDDC-4B2C-8B88-68A26A8835D0}, WmiMethodId: 62) ### Parameters None ### Request Example None ### Response #### Success Response - data (object) - Indicates if the adapter fits for OC ### Response Example None ``` -------------------------------- ### Verify EFI Configuration Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/doc/FEATURES_AND_TESTING.md Checks if the CONFIG_EFI kernel configuration is enabled and verifies that the efivarfs filesystem is mounted with read-write permissions. ```bash #should be y cat /boot/config-$(uname -r) | grep CONFIG_EFI=y # should be rw mount | grep efivars ``` -------------------------------- ### Check Current Fan Curve Settings Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md View the current fan curve configuration by reading the fancurve file in the debug filesystem. ```bash # And check new fan curve sudo cat /sys/kernel/debug/legion/fancurve ``` -------------------------------- ### Make Script Executable Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md Grant execute permissions to the setmyfancurve.sh script before running it. ```bash chmod +x ./setmyfancurve.sh ``` -------------------------------- ### Monitor Fan Speeds and Temperatures Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README_LENOVO_LEGION_5.md Displays current fan speeds and system temperatures using the `sensors` command with the `legion_hwmon` driver. This is useful for real-time monitoring. ```bash sensors legion_hwmon-isa-0000 ``` -------------------------------- ### Set NVIDIA PRIME to On-Demand Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md Configure the NVIDIA PRIME graphics profile to 'on-demand'. This allows the system to use the integrated GPU by default and switch to the discrete GPU only when needed. A restart may be required. ```bash sudo prime-select on-demand ``` -------------------------------- ### Check for Processes on dGPU Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md Use nvidia-smi to ensure no user-initiated programs are running on the discrete GPU before attempting to power it down. Note that the Xorg process is expected and acceptable. ```bash sudo nvidia-smi ``` -------------------------------- ### Enable High-Performance Fan Mode Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README_LENOVO_LEGION_5.md Activates the high-performance fan mode, setting fans to approximately 3100 RPM and enabling performance power mode. This command should be used with caution. ```bash echo 1 | sudo tee /sys/module/legion_laptop/drivers/platform:legion/PNP0C09:00/fan_fullspeed echo 2 | sudo tee /sys/module/legion_laptop/drivers/platform:legion/PNP0C09:00/powermode sudo ~/Downloads/LenovoLegionLinux/.venv/bin/legion_cli maximumfanspeed-enable ``` -------------------------------- ### Directly Access and Change Power Profile via sysfs Source: https://github.com/johnfanv2/lenovolegionlinux/blob/main/README.md Access and modify the system's power profile directly through the sysfs interface. Requires root privileges for changes. Available modes are quiet, balanced, performance, and balanced-performance. ```bash # Access current profile cat /sys/firmware/acpi/platform_profile # Change current profile (AS ROOT): available modes quiet, balanced, performance, balanced-performance # quiet = power-saver echo quiet > /sys/firmware/acpi/platform_profile # or balanced echo balanced > /sys/firmware/acpi/platform_profile # or performance echo performance > /sys/firmware/acpi/platform_profile # or custom-mode = balanced-performance (not available on all models); the LED should turn pink/purple echo balanced-performance > /sys/firmware/acpi/platform_profile ```