├── src ├── update-rtw89 ├── disable-speakers-power-saving ├── auto-battery-conservation └── battery-conservation ├── LICENSE └── README.md /src/update-rtw89: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd ~/rtw89 4 | git pull 5 | sudo make uninstall 6 | make clean 7 | make 8 | /usr/src/kernels/$(uname -r)/scripts/sign-file sha256 ~/.MOK/MOK.priv ~/.MOK/MOK.der rtw89core.ko 9 | /usr/src/kernels/$(uname -r)/scripts/sign-file sha256 ~/.MOK/MOK.priv ~/.MOK/MOK.der rtw89pci.ko 10 | sudo make install 11 | cd - 12 | -------------------------------------------------------------------------------- /src/disable-speakers-power-saving: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "$(id -u)" -ne 0 ]; then 4 | printf "You must run this script as root.\n" 5 | exit 1 6 | fi 7 | 8 | POWER_SAVE_PATH="/sys/module/snd_hda_intel/parameters/power_save" 9 | POWER_CONTROL_PATH="/sys/bus/i2c/drivers/tas2781-hda/i2c-TIAS2781:00/power/control" 10 | 11 | check_paths() { 12 | [ -e "$POWER_SAVE_PATH" ] && [ -e "$POWER_CONTROL_PATH" ] 13 | } 14 | 15 | while ! check_paths; do 16 | sleep 1 17 | done 18 | 19 | # Disable snd_hda_intel power saving 20 | printf "0" > "$POWER_SAVE_PATH" 21 | 22 | # Disable runtime suspend/resume for tas2781 23 | printf "on" > "$POWER_CONTROL_PATH" -------------------------------------------------------------------------------- /src/auto-battery-conservation: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # auto-battery-conservation - Turn battery conservation mode on or off depending 4 | # on the current battery level. 5 | # 6 | # This work is licensed under the Creative Commons Zero v1.0 Universal and 7 | # therefore belongs to the public domain. For more information, please visit: 8 | # 9 | # https://creativecommons.org/publicdomain/zero/1.0 10 | 11 | battery="BAT0" 12 | battery_path="/sys/class/power_supply/$battery" 13 | battery_level=$( cat "$battery_path/capacity" ) 14 | 15 | if [ "$battery_level" -ge "$1" ] 16 | then 17 | echo 1 > /sys/bus/platform/drivers/ideapad_acpi/VPC2004*/conservation_mode 18 | else 19 | echo 0 > /sys/bus/platform/drivers/ideapad_acpi/VPC2004*/conservation_mode 20 | fi 21 | -------------------------------------------------------------------------------- /src/battery-conservation: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function print_help() { 4 | printf "\ 5 | Usage: battery-conservation [OPTION]\n\ 6 | \n\ 7 | Options:\n\ 8 | -h Print help information.\n\ 9 | -n Turn battery conservation on.\n\ 10 | -f Turn battery conservation off.\n\ 11 | -s See battery conservation status.\n" 12 | } 13 | 14 | file_path="/sys/bus/platform/drivers/ideapad_acpi/VPC2004*/conservation_mode" 15 | 16 | while getopts 'hsnf' OPTION 17 | do 18 | case "$OPTION" in 19 | h) 20 | print_help 21 | exit 0 22 | ;; 23 | s) 24 | status=$(bash -c "cat $file_path") 25 | 26 | if [ "$status" = "0" ]; then 27 | echo "Off" 28 | elif [ "$status" = "1" ]; then 29 | echo "On" 30 | else 31 | echo "Unknown" 32 | fi 33 | 34 | exit 0 35 | ;; 36 | n) 37 | sudo bash -c "echo 1 > $file_path" 38 | exit 0 39 | ;; 40 | f) 41 | sudo bash -c "echo 0 > $file_path" 42 | exit 0 43 | ;; 44 | ?) 45 | print_help 46 | exit 1 47 | ;; 48 | esac 49 | done 50 | 51 | print_help 52 | exit 1 53 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Creative Commons Legal Code 2 | 3 | CC0 1.0 Universal 4 | 5 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE 6 | LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN 7 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS 8 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES 9 | REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS 10 | PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM 11 | THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED 12 | HEREUNDER. 13 | 14 | Statement of Purpose 15 | 16 | The laws of most jurisdictions throughout the world automatically confer 17 | exclusive Copyright and Related Rights (defined below) upon the creator 18 | and subsequent owner(s) (each and all, an "owner") of an original work of 19 | authorship and/or a database (each, a "Work"). 20 | 21 | Certain owners wish to permanently relinquish those rights to a Work for 22 | the purpose of contributing to a commons of creative, cultural and 23 | scientific works ("Commons") that the public can reliably and without fear 24 | of later claims of infringement build upon, modify, incorporate in other 25 | works, reuse and redistribute as freely as possible in any form whatsoever 26 | and for any purposes, including without limitation commercial purposes. 27 | These owners may contribute to the Commons to promote the ideal of a free 28 | culture and the further production of creative, cultural and scientific 29 | works, or to gain reputation or greater distribution for their Work in 30 | part through the use and efforts of others. 31 | 32 | For these and/or other purposes and motivations, and without any 33 | expectation of additional consideration or compensation, the person 34 | associating CC0 with a Work (the "Affirmer"), to the extent that he or she 35 | is an owner of Copyright and Related Rights in the Work, voluntarily 36 | elects to apply CC0 to the Work and publicly distribute the Work under its 37 | terms, with knowledge of his or her Copyright and Related Rights in the 38 | Work and the meaning and intended legal effect of CC0 on those rights. 39 | 40 | 1. Copyright and Related Rights. A Work made available under CC0 may be 41 | protected by copyright and related or neighboring rights ("Copyright and 42 | Related Rights"). Copyright and Related Rights include, but are not 43 | limited to, the following: 44 | 45 | i. the right to reproduce, adapt, distribute, perform, display, 46 | communicate, and translate a Work; 47 | ii. moral rights retained by the original author(s) and/or performer(s); 48 | iii. publicity and privacy rights pertaining to a person's image or 49 | likeness depicted in a Work; 50 | iv. rights protecting against unfair competition in regards to a Work, 51 | subject to the limitations in paragraph 4(a), below; 52 | v. rights protecting the extraction, dissemination, use and reuse of data 53 | in a Work; 54 | vi. database rights (such as those arising under Directive 96/9/EC of the 55 | European Parliament and of the Council of 11 March 1996 on the legal 56 | protection of databases, and under any national implementation 57 | thereof, including any amended or successor version of such 58 | directive); and 59 | vii. other similar, equivalent or corresponding rights throughout the 60 | world based on applicable law or treaty, and any national 61 | implementations thereof. 62 | 63 | 2. Waiver. To the greatest extent permitted by, but not in contravention 64 | of, applicable law, Affirmer hereby overtly, fully, permanently, 65 | irrevocably and unconditionally waives, abandons, and surrenders all of 66 | Affirmer's Copyright and Related Rights and associated claims and causes 67 | of action, whether now known or unknown (including existing as well as 68 | future claims and causes of action), in the Work (i) in all territories 69 | worldwide, (ii) for the maximum duration provided by applicable law or 70 | treaty (including future time extensions), (iii) in any current or future 71 | medium and for any number of copies, and (iv) for any purpose whatsoever, 72 | including without limitation commercial, advertising or promotional 73 | purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each 74 | member of the public at large and to the detriment of Affirmer's heirs and 75 | successors, fully intending that such Waiver shall not be subject to 76 | revocation, rescission, cancellation, termination, or any other legal or 77 | equitable action to disrupt the quiet enjoyment of the Work by the public 78 | as contemplated by Affirmer's express Statement of Purpose. 79 | 80 | 3. Public License Fallback. Should any part of the Waiver for any reason 81 | be judged legally invalid or ineffective under applicable law, then the 82 | Waiver shall be preserved to the maximum extent permitted taking into 83 | account Affirmer's express Statement of Purpose. In addition, to the 84 | extent the Waiver is so judged Affirmer hereby grants to each affected 85 | person a royalty-free, non transferable, non sublicensable, non exclusive, 86 | irrevocable and unconditional license to exercise Affirmer's Copyright and 87 | Related Rights in the Work (i) in all territories worldwide, (ii) for the 88 | maximum duration provided by applicable law or treaty (including future 89 | time extensions), (iii) in any current or future medium and for any number 90 | of copies, and (iv) for any purpose whatsoever, including without 91 | limitation commercial, advertising or promotional purposes (the 92 | "License"). The License shall be deemed effective as of the date CC0 was 93 | applied by Affirmer to the Work. Should any part of the License for any 94 | reason be judged legally invalid or ineffective under applicable law, such 95 | partial invalidity or ineffectiveness shall not invalidate the remainder 96 | of the License, and in such case Affirmer hereby affirms that he or she 97 | will not (i) exercise any of his or her remaining Copyright and Related 98 | Rights in the Work or (ii) assert any associated claims and causes of 99 | action with respect to the Work, in either case contrary to Affirmer's 100 | express Statement of Purpose. 101 | 102 | 4. Limitations and Disclaimers. 103 | 104 | a. No trademark or patent rights held by Affirmer are waived, abandoned, 105 | surrendered, licensed or otherwise affected by this document. 106 | b. Affirmer offers the Work as-is and makes no representations or 107 | warranties of any kind concerning the Work, express, implied, 108 | statutory or otherwise, including without limitation warranties of 109 | title, merchantability, fitness for a particular purpose, non 110 | infringement, or the absence of latent or other defects, accuracy, or 111 | the present or absence of errors, whether or not discoverable, all to 112 | the greatest extent permissible under applicable law. 113 | c. Affirmer disclaims responsibility for clearing rights of other persons 114 | that may apply to the Work or any use thereof, including without 115 | limitation any person's Copyright and Related Rights in the Work. 116 | Further, Affirmer disclaims responsibility for obtaining any necessary 117 | consents, permissions or other rights required for any use of the 118 | Work. 119 | d. Affirmer understands and acknowledges that Creative Commons is not a 120 | party to this document and has no duty or obligation with respect to 121 | this CC0 or use of the Work. 122 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Using Linux on Lenovo Legion 2 | ============================ 3 | 4 | [f37 update]: https://github.com/cszach/linux-on-lenovo-legion/issues/3 5 | 6 | This is a compilation of instructions and resources for those who use a Linux 7 | system (e.g. GNU plus Linux) on a Lenovo Legion laptop. More notes will be 8 | added as I discover more things. 9 | 10 | Contributing 11 | ------------ 12 | 13 | Any suggestion will be **very** appreciated. Feel free to open issues and pull 14 | requests for suggestions, comments, and questions. If you have a workaround that 15 | you do not see presented here, please, **please** either open an issue or pull 16 | request. The goal here is to compile all the working solutions so everyone does 17 | not have to spend countless hours digging for solutions online. 18 | 19 | My system 20 | --------- 21 | 22 | - **Machine**: Lenovo Legion 5 15ACH6H (Ryzen + NVIDIA) 23 | - **Operating system**: Fedora 39 24 | - **Desktop environment**: GNOME 45.1 25 | - **Windowing system**: Wayland 26 | - **Linux kernel's version** (as of latest commit): `6.5.10-300.fc39.x86_64` 27 | 28 | Table of Content 29 | ---------------- 30 | 31 | 1. [Wi-Fi](#wi-fi) 32 | - [Downloading and installing the driver](#downloading-and-installing-the-driver) 33 | - [Kernel update](#kernel-update) 34 | - [Acknowledgment](#acknowledgment) 35 | 2. [Brightness](#brightness) 36 | - [Solutions](#solutions) 37 | - [Temporary solution](#temporary-solution) 38 | - [See also](#see-also) 39 | 3. [Battery conservation mode](#battery-conservation-mode) 40 | - [Scripts](#scripts) 41 | 4. [Launch applications on dedicated graphics card](#launch-applications-on-dedicated-graphics-card) 42 | - [Try it now](#try-it-now) 43 | - [Steam](#steam) 44 | - [Aliases](#aliases) 45 | - [Google Chrome and WebGPU](#google-chrome-and-webgpu) 46 | - [Firefox and WebGPU](#firefox-and-webgpu) 47 | 5. [Windowing system](#windowing-system) 48 | - [X11](#x11) 49 | - [Wayland](#wayland) 50 | - [See also](#see-also-1) 51 | 6. [Keyboard's RGB](#keyboards-rgb) 52 | 7. [Fan control](#fan-control) 53 | 8. [FPC fingerprint](#fpc-fingerprint) 54 | 9. [Speakers not working](#speakers-not-working) 55 | 56 | Wi-Fi 57 | ----- 58 | 59 | > **Fedora 37+ update**: as documented in [#3][f37 update] (thanks @hrkrx) and 60 | > from my personal experience with Fedora 38, wi-fi seems to work out of the box 61 | > now for these two Fedora versions. 62 | 63 | This is perhaps the most frustrating issue and the problem you would want to fix 64 | first. It is likely that your system does not have the driver for Realtek 65 | RTL8852AE 802.11ax. Thus, you will need to download and install it. 66 | 67 | ### Downloading and installing the driver 68 | 69 | Get ready to work in the terminal! You don't need root permissions here; 70 | commands requiring root privileges will have `sudo` in them. 71 | 72 | 1. **Temporarily connect to the Internet using Ethernet or a wireless USB 73 | adapter.** You may also use another computer; 74 | 2. **Download/clone [this repository](https://github.com/lwfinger/rtw89).** You 75 | can clone any of the `main`, `v5`, `v6`, and `v7` branches. I tried the 76 | `main` branch and the `v7` branch, both of which worked (I am currently using 77 | the `v7`); 78 | 3. **Create a directory for storing a MOK** (Machine Owner Key) to allow the 79 | driver to run. A good choice is `~/.MOK` (we will be using it for the rest 80 | of the instructions); 81 | 82 | ```bash 83 | mkdir ~/.MOK 84 | ``` 85 | 86 | 4. **Open the directory you created in step 3.** 87 | 88 | ```bash 89 | cd ~/.MOK 90 | ``` 91 | 92 | 5. **Request a new MOK key pair.** 93 | 94 | ```bash 95 | openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -nodes -days 36500 -subj "/CN=Custom MOK/" 96 | ``` 97 | 98 | 6. **Import the MOK key.** 99 | 100 | ```bash 101 | sudo mokutil --import MOK.der 102 | ``` 103 | 104 | 7. **Reboot.** Upon seeing the splash screen with the Legion logo, you may see a 105 | blue screen that asks if you want to manage MOK keys. **Select "Enroll MOK" 106 | on the menu and accept to enroll the new MOK key.** After this process, your 107 | OS will boot. 108 | 8. **Open a terminal in the `rtw89` repository clone.** It is the directory you 109 | cloned the `rtw89` repository into in step 2. 110 | 9. **Compile the driver, sign the compiled driver files with the MOK key, and 111 | install the driver.** 112 | 113 | ```bash 114 | make 115 | /usr/src/kernels/$(uname -r)/scripts/sign-file sha256 ~/.MOK/MOK.priv ~/.MOK/MOK.der rtw89core.ko 116 | /usr/src/kernels/$(uname -r)/scripts/sign-file sha256 ~/.MOK/MOK.priv ~/.MOK/MOK.der rtw89pci.ko 117 | sudo make install 118 | ``` 119 | 120 | 10. **Reboot.** Your device should be able to connect to Wi-Fi networks now. 121 | 122 | ### Kernel update 123 | 124 | After you have updated your Linux kernel, you need to recompile the driver and 125 | install it again. 126 | 127 | 1. **Reboot.** If you have already rebooted after updating the kernel, you may 128 | skip this step. 129 | 2. **Open the terminal in the `rtw89` directory.** 130 | 3. **Follow the steps below.** The last 4 commands is exactly the same as the 131 | ones in step 9 of the previous section. Note that if you have deleted the MOK 132 | key, you will have to complete steps 3-7 of the previous section. 133 | 134 | ```bash 135 | git pull 136 | sudo make uninstall 137 | make clean 138 | make 139 | /usr/src/kernels/$(uname -r)/scripts/sign-file sha256 ~/.MOK/MOK.priv ~/.MOK/MOK.der rtw89core.ko 140 | /usr/src/kernels/$(uname -r)/scripts/sign-file sha256 ~/.MOK/MOK.priv ~/.MOK/MOK.der rtw89pci.ko 141 | sudo make install 142 | ``` 143 | 144 | 4. **Reboot.** 145 | 146 | A Bash script that automates this process can be found in [`src`](src/). Be sure 147 | to modify the paths and file names accordingly. 148 | 149 | ### Acknowledgment 150 | 151 | Thanks to **@lwfinger** and other contributors of the **rtw89** GitHub 152 | repository for their work on the open-source driver. Many thanks to 153 | **@lukinoway** for sharing how they installed the driver on Fedora 34. 154 | 155 | Brightness 156 | ---------- 157 | 158 | > **Fedora 37+ update**: Brightness controls work out of the box. 159 | 160 | Having troubles changing the screen brightness? Fn + F5/F6 does not work? Here 161 | are some things I have found. 162 | 163 | ### Solutions 164 | 165 | - **Try the `amdgpu.backlight=0` parameter in your kernel boot parameters.** 166 | When you boot your machine, press E on your keyboard when you see the GRUB 167 | boot menu. Then insert `amdgpu.backlight=0` into the kernel parameters. This 168 | addition is temporary so you can see if it works. If it does, you can add the 169 | parameter permanently e.g. using `grubby`: 170 | 171 | ```bash 172 | sudo grubbby --args="amdgpu.backlight=0 --update-kernel $(sudo grubby --default-kernel)" 173 | ``` 174 | 175 | - The AMD iGPU might not support for brightness control due to a bug. Thus, you 176 | can **try using the NVIDIA dGPU for this**. Please refer to the 177 | [_See also_](#see-also) section below. 178 | 179 | ### Temporary solution 180 | 181 | If none of the solution works for you, here is a temporary workaround: 182 | 183 | ```bash 184 | xrandr --output MONITOR --brightness BRIGHTNESS 185 | ``` 186 | 187 | Replace `MONITOR` with the correct monitor identifier (try 188 | `xrandr --listmonitors` for a list) and `BRIGHTNESS` with the appropriate 189 | brightness from 0 to 1. Values over 1 are also accepted but not recommended. 190 | 191 | For example, here is my output of `xrandr --listmonitors`: 192 | 193 | ``` 194 | Monitors: 2 195 | 0: +*eDP 1920/344x1080/194+0+0 eDP 196 | 1: +HDMI-1-0 2560/597x1440/336+1920+0 HDMI-1-0 197 | ``` 198 | 199 | I connect my laptop to an external monitor via HDMI, which is why you see 2 200 | entries here (the first entry is the Legion laptop's monitor). Hence, to set the 201 | laptop's monitor's brightness to 0.5, I run: 202 | 203 | ```bash 204 | xrandr --output eDP --brightness 0.5 205 | ``` 206 | 207 | This solution does not work very well with night light, however. As soon as 208 | night light starts, you will lose what you have set for brightness. If you 209 | attempt to set brightness using this method again, night light will turn off. 210 | 211 | ### See also 212 | 213 | - **[lenovo-legion5-15arh05-scripts](https://github.com/antony-jr/lenovo-legion5-15arh05-scripts)** 214 | (repository on GitHub). Please see inside the folders `AMDGPUFIX` and 215 | `XOrgConfigurationNvidia`. The repository contains many other useful fixes you 216 | might want for your Legion laptop, so I recommend checking the whole thing 217 | out. Many thanks to Antony Jr for this work; 218 | - . 219 | 220 | Battery conservation mode 221 | ------------------------- 222 | 223 | It is not a good idea to leave your laptop plugged in when it is already 100% 224 | charged, as this will damage your laptop's battery's health. However, it is also 225 | tiresome to have to manually unplug your laptop. Ideally, you want your laptop 226 | to automatically stop the charge after the battery reaches a certain level 227 | while it is still plugged in. Battery conservation does this. Windows users 228 | enjoy enabling this feature in Lenovo Vantage. 229 | 230 | On Linux, to enable battery conservation (requires sudo permission): 231 | 232 | ```bash 233 | sudo bash -c "echo 1 > /sys/bus/platform/drivers/ideapad_acpi/VPC2004*/conservation_mode" 234 | ``` 235 | 236 | …and to disable it, replace the `1` with `0`. 237 | 238 | ```bash 239 | sudo bash -c "echo 0 > /sys/bus/platform/drivers/ideapad_acpi/VPC2004*/conservation_mode" 240 | ``` 241 | 242 | When battery conservation mode is on, your battery will stop charging if it is 243 | **60% full** or more. If you need to charge your laptop to, say, 80% so you can 244 | use it unplugged later, you will have to disable battery conservation to let 245 | your device charge and turn conservation on when it reaches 80%. See below for 246 | a cronjob that does this for you. 247 | 248 | ### Scripts 249 | 250 | For convenience, I have written some scripts to help you control battery 251 | conservation. 252 | 253 | - [`battery-conservation`](src/battery-conservation): A utility to see the 254 | status of battery conservation and turn the feature on/off. Use `-s` to see 255 | the status, `-n` to turn conservation on, `-f` to turn off. You can run the 256 | script as normal user, it will ask for `sudo` when necessary; 257 | - [`auto-battery-conservation`](src/auto-battery-conservation): Turns battery 258 | conservation on if the battery level is greater than or equal to a specified 259 | integer, and off if less than. You must specify the integer as the first and 260 | only command line argument to the script. This is useful if you don't like the 261 | 60% battery conservation trigger. The script is designed to be used as a 262 | cronjob; you will need to run it as root, so open the cron editor using 263 | `sudo crontab -e` and add the following cron entry: 264 | ``` 265 | */10 * * * * auto-battery-conservation 80 266 | ``` 267 | 268 | > **Note**: You might have to put `bash /path/to/the/script 80` instead of just 269 | > `auto-battery-conservation 80` in the cron entry. 270 | 271 | Feel free to, of course, use another number if you like. 272 | 273 | Copy these scripts to a `PATH` directory. I personally use `~/.local/bin`. 274 | 275 | Launch applications on dedicated graphics card 276 | ----------------------------------------------- 277 | 278 | > **Note**: Before you read this section, please have a dedicated graphics card 279 | > driver installed. This is quite dependent on your OS and desktop environment, 280 | > so I don't provide the instructions here (Fedora users are better off sticking 281 | > to [RPM Fusion's how-to](https://rpmfusion.org/Howto/NVIDIA?highlight=%28%5CbCategoryHowto%5Cb%29)). 282 | 283 | Which graphics card is your machine running on? 284 | 285 | ``` 286 | glxinfo | egrep "OpenGL vendor|OpenGL renderer" 287 | ``` 288 | 289 | - If it is your dedicated graphics card (dGPU), I can think of 2 reasons (please 290 | contribute more, I am not an expert): 1. you have set the dGPU as your primary 291 | GPU; 2. you are in Legion's discrete graphics mode (configurable when boot). 292 | While this is totally fine if you know what you are doing, I find it overkill 293 | to have everything run on dGPU when I don't need it most of the time (consumes 294 | more power, increases your electricity bills, etc.); 295 | - If it is your integrated graphics card (iGPU), this section is for you. 296 | 297 | While in hybrid graphics mode, we are interested in launching certain 298 | applications, such as Blender and video games, on our dGPU, to take advantage 299 | of faster graphics computing power. GNOME has already allowed you to do so 300 | by right clicking an application and selecting "Launch using Discrete Graphics 301 | Card". But there is a more universal way to launch any application on the dGPU. 302 | 303 | If you are using an AMD dGPU, you can start an application on the dGPU from the 304 | terminal by setting the environment variable `DRI_PRIME`: 305 | 306 | ``` 307 | DRI_PRIME=1 command args... 308 | ``` 309 | 310 | And if you are using NVIDIA's: 311 | 312 | ``` 313 | __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia command args... 314 | ``` 315 | 316 | ### Try it now 317 | 318 | Start `glxgears`: 319 | 320 | ```bash 321 | glxgears -info | grep GL_RENDERER 322 | ``` 323 | 324 | ![Screenshot of glxgears](https://user-images.githubusercontent.com/24489228/222505570-8c8a7951-f225-4cfe-9f1e-208a4bfdbda2.png) 325 | 326 | The program shows an animation of three intermeshing gears rotating. In the 327 | terminal output, you should see your iGPU. This is mine (AMD iGPU, NVIDIA dGPU): 328 | 329 | ``` 330 | GL_RENDERER = AMD Radeon Graphics (renoir, LLVM 14.0.0, DRM 3.48, 6.0.18-200.fc36.x86_64) 331 | ``` 332 | 333 | Kill the application. Now set the appropriate environment variable(s) and launch 334 | it again. So for example, I would use the following command: 335 | 336 | ```bash 337 | __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia glxgears -info | grep GL_RENDERER 338 | ``` 339 | 340 | And the result: 341 | 342 | ``` 343 | GL_RENDERER = NVIDIA GeForce RTX 3060 Laptop GPU/PCIe/SSE2 344 | ``` 345 | 346 | ### Steam 347 | 348 | The technique also applies to Steam games. In your _Library_, edit the 349 | _Properties_ of the game that you wish to run on your graphics card. Under 350 | launch options, edit the launch command, and use `%command%` as the placeholder 351 | for the actual game command. For example, here is my launch command for Quake II 352 | RTX (NVIDIA dGPU): 353 | 354 | ``` 355 | __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia %command% 356 | ``` 357 | 358 | ### Aliases 359 | 360 | It would be a pain to have to set the variables every time. For convenience, put 361 | this in your `.bashrc`, or wherever you set your Shell's configuration: 362 | 363 | - AMD: 364 | ```bash 365 | alias amd="DRI_PRIME=1" 366 | ``` 367 | - NVIDIA: 368 | ```bash 369 | alias nvidia="__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia" 370 | ``` 371 | 372 | I can then start glxgears on my dGPU just by typing `nvidia glxgears`. Happy 373 | computing! 374 | 375 | ### Google Chrome and WebGPU 376 | 377 | Web applications could benefit from GPU computing too! Launch Google Chrome on 378 | your dedicated graphics card (see instructions above), go to `chrome://gpu`, and 379 | navigate to the _Driver Information_ section to verify that Chrome is using the 380 | dGPU, and you are good to go! 381 | 382 | [Google Chrome 113+ ships with WebGPU][chrome webgpu], a new web graphics API 383 | that is the successor to WebGL. To enable WebGPU: 384 | 385 | 1. In `chrome://settings`, make sure that hardware acceleration is enabled; 386 | 2. Go to `chrome://flags`, and enable the WebGPU and Vulkan flags; 387 | 3. **Close all Chrome windows**, and relaunch Google Chrome on dedicated 388 | graphics card with the `--enable-unsafe-webgpu` option: 389 | 390 | ```bash 391 | # nvidia here is the alias from the previous section 392 | nvidia google-chrome --enable-unsafe-webgpu 393 | ``` 394 | 395 | To make sure that WebGPU is working, go to `chrome://gpu`. It should say 396 | "WebGPU: Hardware accelerated" in the _Graphics Feature Status_ section. Try out 397 | some [WebGPU samples][webgpu samples]! 398 | 399 | [chrome webgpu]: https://developer.chrome.com/blog/webgpu-release/ 400 | 401 | ### Firefox and WebGPU 402 | 403 | I could not make Firefox Developer Edition run on my dGPU. However, Firefox 404 | Nightly works (just by launching on dedicated graphics card, see instructions 405 | above). Go to `about:support`, navigate to the _Graphics_ section and verify 406 | that Firefox is using dGPU. 407 | 408 | Firefox Nightly also comes with WebGPU enabled by default (check that 409 | `dom.webgpu.enabled` is set to `true` in `about:config`). Visit the [WebGPU 410 | samples][webgpu samples] and see if WebGPU is working. 411 | 412 | [webgpu samples]: https://webgpu.github.io/webgpu-samples/ 413 | 414 | Windowing system 415 | ---------------- 416 | 417 | > This section is reported on a Legion with NVIDIA dGPU. Please contribute to 418 | > it especially if you have experience dealing with an AMD dGPU. 419 | 420 | Pick your poison. 421 | 422 | ### X11 423 | 424 | Pros: 425 | - handles night light on the external monitor correctly; 426 | - lets you use `nvidia-settings`. 427 | 428 | Cons: 429 | - external monitor is very laggy, even when set with high FPS, making it nearly 430 | unusable. 431 | 432 | ### Wayland 433 | 434 | Pros: 435 | - no external monitor lag. 436 | 437 | Cons: 438 | - night light does not apply on external monitor (at least with my conf.); 439 | - `nvidia-settings` is not supported; 440 | - no hardware-accelerated video encoding with VDPAU. 441 | 442 | > **Note**: Having troubles with monitor displays on Wayland? Try enabling 443 | > **KMS** by adding `nvidia-drm.modeset=1` to your kernel parameters. Case in 444 | > point, I connected my external monitor to my Legion through an HDMI cable and 445 | > somehow only the external monitor was working; the laptop monitor was empty. 446 | > After making this fix, both monitors started to work normally. Read more 447 | > [here](https://rpmfusion.org/Howto/NVIDIA?highlight=%28%5CbCategoryHowto%5Cb%29#KMS). 448 | > NVIDIA drivers only. 449 | 450 | ### See also 451 | 452 | - 453 | - 454 | - [Requirements and limitations of XWayland on NVIDIA](http://us.download.nvidia.com/XFree86/Linux-x86_64/510.60.02/README/xwayland.html) 455 | 456 | Keyboard's RGB 457 | -------------- 458 | 459 | **@4JX** created **[an awesome cross-platform application][keyboard rgb]** for 460 | controlling the RGB lights of Lenovo Legion laptops' keyboards. You can choose 461 | from one of the presets (some of which require manual color setting) or even 462 | create your own effects (please see the project on GitHub for more details). You 463 | can also set the speed of the effect being used and the lights' brightness. The 464 | program can be run in the CLI or the GUI and works out of the box on my machine. 465 | 466 | ![Screenshot of the application](https://user-images.githubusercontent.com/24489228/145649411-944838e1-ed89-4a96-bd29-20138baa9707.png) 467 | 468 | [keyboard rgb]: https://github.com/4JX/L5P-Keyboard-RGB 469 | 470 | Fan control 471 | ----------- 472 | 473 | **@johnfanv2** created a tool that lets you create custom fan curves, monitor 474 | fan speeds and temperatures, switch between power modes, and more! It is called 475 | **[LenovoLegionLinux](https://github.com/johnfanv2/LenovoLegionLinux)** and I 476 | highly recommending checking out and starring the project. Thanks for letting me 477 | know about this great project! 478 | 479 | ![Screenshot of LenovoLegionLinux's fan curve configuration GUI](https://user-images.githubusercontent.com/24489228/222505692-e1cf7345-4951-4668-a57d-29be3c04f051.jpg) 480 | 481 | ![Screenshot of LenovoLegionLinux's fan monitor](https://user-images.githubusercontent.com/24489228/222505780-edce0904-5da5-4952-bed1-2b3519de7cd8.png) 482 | 483 | Screenshots courtesy of **@johnfanv2**. 484 | 485 | FPC fingerprint 486 | --------------- 487 | 488 | > Contributed by **@kasra3422** for Ubuntu, thanks. 489 | 490 | ```bash 491 | $ sudo add-apt-repository ppa:libfprint-tod1-group/ppa 492 | $ sudo apt update 493 | $ ubuntu-drivers list 494 | libfprint-2-tod1-fpc 495 | $ sudo apt install libfprint-2-tod1-fpc 496 | $ sudo reboot 497 | ``` 498 | 499 | Read more [here](https://bugs.launchpad.net/ubuntu/+source/libfprint/+bug/1965931). 500 | 501 | Speakers not working 502 | -------------------- 503 | 504 | If your integrated speakers produce no sound, but kernel and sound server seem to detect the sound card just fine, 505 | and the speaker connectors on the motherboard are intact and firmly attached, a likely reason for no sound is 506 | power saving features of the laptop. This can be disabled with [the script](src/disable-speakers-power-saving) 507 | 508 | [Source@forum.manjaro.org](https://forum.manjaro.org/t/finally-got-sound-working-on-lenovo-legion-pro-7-16arx8h/164447) 509 | --------------------------------------------------------------------------------