Skip to content

Add nvidia-optimus plugin - #939

Open
joniler wants to merge 2 commits into
noctalia-dev:mainfrom
joniler:add-nvidia-optimus
Open

Add nvidia-optimus plugin#939
joniler wants to merge 2 commits into
noctalia-dev:mainfrom
joniler:add-nvidia-optimus

Conversation

@joniler

@joniler joniler commented Jul 1, 2026

Copy link
Copy Markdown

nvidia-optimus

Monitor and control an NVIDIA Optimus dGPU on Hyprland from the bar. A theme-tinted NVIDIA "eye" shows the dGPU's power state (accent = awake, neutral = asleep); clicking it opens a panel with a Battery ⇄ HDMI-Ready toggle, live power/temp/VRAM, and the list of processes holding the GPU (compute + graphics, including container/root procs that lsof can't see).

Why: on Hyprland an NVIDIA Optimus dGPU often won't RTD3-suspend even when idle — the compositor's EGL keeps it pinned — quietly draining battery. Meanwhile the HDMI port is frequently wired to the dGPU, so you can't just disable it. This plugin switches between "let the dGPU sleep" (drop it from AQ_DRM_DEVICES + force mesa-only EGL) and "HDMI-Ready", and surfaces the true power state at a glance.

Notes for review:

  • Ships three small bash helpers under scripts/ (run via bash, no exec bit required). They read sysfs / nvidia-smi and edit the user's ~/.config/hypr/env.conf (backed up on every change). Both GPUs are auto-detected from sysfs — nothing machine-specific is hardcoded.
  • The background poll is sysfs-only and never wakes the dGPU (name resolved from pci.ids, connectors on a sleeping dGPU are not probed). nvidia-smi runs only while the panel is open, and only when the GPU is already awake.
  • Hyprland-specific (uses AQ_DRM_DEVICES); requires the proprietary NVIDIA driver + nvidia-drm.modeset=1.
  • Precedent for hardware/script plugins in the registry: asus-um5606-fan-state, battery-and-power-management, arch-updater.

Developed at https://github.com/joniler/noctalia-nvidia-optimus

Monitor and control an NVIDIA Optimus dGPU on Hyprland: toggle Battery
(dGPU RTD3-suspends via AQ_DRM_DEVICES + mesa-only EGL) vs HDMI-Ready,
with a theme-tinted eye, wake-free sysfs polling, GPU auto-detection, and
a live process list.
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Automatic Code Quality Review


File: nvidia-optimus/Panel.qml

  • (H) Line 187: Use translations instead of hardcoded text. Instead of: "Example Label". To: pluginApi?.tr("panel.example-label")
+            text: "External display"
  • (H) Line 210: Use translations instead of hardcoded text. Instead of: "Example Label". To: pluginApi?.tr("panel.example-label")
+            text: "GPU processes"
  • (H) Line 278: Use translations instead of hardcoded text. Instead of: "Example Label". To: pluginApi?.tr("panel.example-label")
+          text: "AQ_DRM_DEVICES is read at session start."
  • (H) Line 284: Use translations instead of hardcoded text. Instead of: "Example Label". To: pluginApi?.tr("panel.example-label")
+          text: "Apply now (log out)"

File: nvidia-optimus/Settings.qml

  • (H) Line 21: Use translations instead of hardcoded text. Instead of: "Example Label". To: pluginApi?.tr("panel.example-label")
+      text: "NVIDIA Optimus"
  • (H) Line 32: Use translations instead of hardcoded text. Instead of: "Example Label". To: pluginApi?.tr("panel.example-label")
+      text: "The bar toggle flips Hyprland's AQ_DRM_DEVICES between Battery (iGPU only — the NVIDIA dGPU runtime-suspends, no HDMI) and HDMI-Ready (iGPU + dGPU — external outputs work). It edits ~/.config/hypr/env.conf (backed up alongside) and applies on the next login. The bar icon is theme-tinted: accent when the dGPU is awake, neutral when asleep. Stats poll every 2s from a bundled sysfs-only script that never wakes the GPU; nvidia-smi runs only while this panel is open, and only when the GPU is already awake."
  • (H) Line 40: Use translations instead of hardcoded text. Instead of: "Example Label". To: pluginApi?.tr("panel.example-label")
+      text: "Requires: Hyprland (aquamarine), an NVIDIA Optimus laptop with the proprietary driver + nvidia-drm.modeset=1. Override the env file with $HYPR_ENV_FILE if yours lives elsewhere."

1 similar comment
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Automatic Code Quality Review


File: nvidia-optimus/Panel.qml

  • (H) Line 187: Use translations instead of hardcoded text. Instead of: "Example Label". To: pluginApi?.tr("panel.example-label")
+            text: "External display"
  • (H) Line 210: Use translations instead of hardcoded text. Instead of: "Example Label". To: pluginApi?.tr("panel.example-label")
+            text: "GPU processes"
  • (H) Line 278: Use translations instead of hardcoded text. Instead of: "Example Label". To: pluginApi?.tr("panel.example-label")
+          text: "AQ_DRM_DEVICES is read at session start."
  • (H) Line 284: Use translations instead of hardcoded text. Instead of: "Example Label". To: pluginApi?.tr("panel.example-label")
+          text: "Apply now (log out)"

File: nvidia-optimus/Settings.qml

  • (H) Line 21: Use translations instead of hardcoded text. Instead of: "Example Label". To: pluginApi?.tr("panel.example-label")
+      text: "NVIDIA Optimus"
  • (H) Line 32: Use translations instead of hardcoded text. Instead of: "Example Label". To: pluginApi?.tr("panel.example-label")
+      text: "The bar toggle flips Hyprland's AQ_DRM_DEVICES between Battery (iGPU only — the NVIDIA dGPU runtime-suspends, no HDMI) and HDMI-Ready (iGPU + dGPU — external outputs work). It edits ~/.config/hypr/env.conf (backed up alongside) and applies on the next login. The bar icon is theme-tinted: accent when the dGPU is awake, neutral when asleep. Stats poll every 2s from a bundled sysfs-only script that never wakes the GPU; nvidia-smi runs only while this panel is open, and only when the GPU is already awake."
  • (H) Line 40: Use translations instead of hardcoded text. Instead of: "Example Label". To: pluginApi?.tr("panel.example-label")
+      text: "Requires: Hyprland (aquamarine), an NVIDIA Optimus laptop with the proprietary driver + nvidia-drm.modeset=1. Override the env file with $HYPR_ENV_FILE if yours lives elsewhere."

Addresses code-quality review: adds i18n/en.json and replaces hardcoded
strings in Panel/Settings/BarWidget with pluginApi?.tr() lookups.
@joniler
joniler force-pushed the add-nvidia-optimus branch from 5ed9fc5 to b851aff Compare July 1, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant