Tray application enabling the user to switch between Hybrid and discrete graphics mode.
Find a file
pongsn b03f0a182d Add active GPU indicator and dGPU process viewer in hybrid mode
In hybrid mode, the tray icon chip body now fills red (iGPU active) or
green (dGPU active) based on whether any process has /dev/nvidia0 open,
polled every 5s. Uses fuser instead of runtime_status because
nvidia-drm.modeset=1 keeps the PCI device active regardless of user-space
usage. Also adds a "Show dGPU processes" menu item (nvidia-smi, hybrid
mode only).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29 14:11:12 -05:00
.gitignore Initial release: GPU mode tray app for Lenovo Legion 2026-06-29 02:23:11 -05:00
com.lenovolegion.gpumodetray.policy Initial release: GPU mode tray app for Lenovo Legion 2026-06-29 02:23:11 -05:00
install.sh Rename project to legion-gpu-mode-switcher 2026-06-29 02:25:43 -05:00
legion-gpu-mode-switcher.desktop Rename project to legion-gpu-mode-switcher 2026-06-29 02:25:43 -05:00
main.py Add active GPU indicator and dGPU process viewer in hybrid mode 2026-06-29 14:11:12 -05:00
README.md Add active GPU indicator and dGPU process viewer in hybrid mode 2026-06-29 14:11:12 -05:00

Legion GPU Mode Switcher

A lightweight KDE system tray application for switching GPU modes on Lenovo Legion laptops running the lenovolegionlinux driver.

Features

  • Shows current GPU mode in the system tray (chip icon: red/green split outline for Hybrid, solid green for NVIDIA only)
  • In Hybrid mode, the chip body fills red (iGPU active) or green (dGPU active) to show which GPU is currently doing work — updates every 5 seconds via /dev/nvidia0 usage detection
  • Switch between Hybrid (AMD iGPU drives internal display, NVIDIA exposes HDMI) and NVIDIA only (dGPU drives everything) with one click
  • No password prompt for the active desktop session (polkit allow_active: yes)
  • Tracks pending mode switches before reboot — shows an orange badge on the icon and allows cancelling the switch
  • Triggers a reboot prompt after switching; also offers "Reboot now" from the tray menu
  • In Hybrid mode, shows a "Show dGPU processes" menu item listing which processes are currently using the dGPU (via nvidia-smi)
  • Installs itself as a KDE autostart entry

Compatibility

Component Requirement
Hardware Lenovo Legion laptop with MUX switch support via lenovolegionlinux
Init system systemd (for systemctl reboot)
Desktop Any DE with system tray support (KDE, XFCE, …). GNOME on Wayland requires the AppIndicator extension
Autostart XDG-compliant DEs (~/.config/autostart/)

Not Arch or KDE specific — works on any systemd-based distro (Ubuntu, Fedora, openSUSE, Debian, etc.) as long as the lenovolegionlinux driver is installed.

Tested on

  • Lenovo Legion 5 Pro Gen 7 (BIOS JUCN66WW)
  • AMD Radeon 680M (iGPU) + NVIDIA GeForce RTX 3070 Ti Laptop GPU
  • KDE Plasma 6.6 on Wayland, kernel 6.18, Manjaro Linux

Note: This machine requires force=1 for the legion_laptop module and the --donotexpecthwmon flag for legion_cli. Other Legion models with full hwmon support may work without these workarounds — the commands would need adjusting in main.py and the sudoers/polkit config.

Dependencies

  • Python 3.8+
  • PyQt6
    • Arch/Manjaro: sudo pacman -S python-pyqt6
    • Ubuntu/Debian: sudo apt install python3-pyqt6
    • Fedora: sudo dnf install python3-qt6
    • Or via pip: pip install pyqt6
  • lenovolegionlinux driver (legion_cli must be in $PATH)
  • polkit (pkexec)

Installation

git clone https://github.com/pongsn/legion-gpu-mode-switcher.git
cd legion-gpu-mode-switcher
sudo bash install.sh

install.sh will:

  1. Install the polkit policy to /usr/share/polkit-1/actions/ (enables passwordless switching for the active session)
  2. Install the app to /usr/local/bin/legion-gpu-mode-switcher
  3. Install the autostart entry to ~/.config/autostart/ (starts on next login)

Usage

legion-gpu-mode-switcher &

Right-click the tray icon to switch GPU mode. A reboot is required for any mode change to take effect — this is a hardware MUX limitation, same as on Windows.