Files
dotfiles/nvidia-power-tray
2026-08-08 17:31:31 +02:00
..
2026-08-08 17:31:31 +02:00
2026-08-08 17:31:31 +02:00
2026-08-08 17:31:31 +02:00

nvidia-power-tray

A tray indicator showing the PCI power state of the NVIDIA GPU — D0 when the card is awake, D3cold when the driver has runtime-suspended it. Useful on hybrid-graphics laptops to see at a glance whether something is holding the discrete GPU on.

The state is read from /sys/bus/pci/devices/<address>/power_state. That is a plain sysfs read and does not wake a suspended card — unlike nvidia-smi or lspci, both of which touch the device and pull it back into D0. For the same reason the device name in the menu is resolved from /usr/share/misc/pci.ids instead of by shelling out to lspci.

Contents

.local/bin/nvidia-power-tray                     # the indicator
.config/systemd/user/nvidia-power-tray.service   # runs it in the GNOME session

Dependencies

sudo apt install gir1.2-ayatanaappindicator3-0.1 gir1.2-gtk-3.0 python3-gi

The script also accepts the older AppIndicator3 namespace if that is what the system ships.

Install

cd ~/dotfiles
stow nvidia-power-tray
systemctl --user daemon-reload
systemctl --user enable --now nvidia-power-tray.service

The unit is WantedBy=graphical-session.target, so it starts with the GNOME session and stops with it.

Usage

The icon reflects the state (power-profile-performance-symbolic for D0, power-profile-power-saver-symbolic for D3hot/D3cold) and the label next to it is the raw state string. The menu shows the device, PCI address, bound driver, power state, runtime-PM status and runtime-PM control setting, plus Refresh now and Quit.

The PCI address is autodetected: the first NVIDIA (vendor 0x10de) display controller, preferring one with a driver bound. Override it, or the 5 second poll interval, with flags or environment variables:

nvidia-power-tray --address 0000:01:00.0 --interval 10
NVIDIA_POWER_TRAY_ADDRESS=0000:01:00.0 NVIDIA_POWER_TRAY_INTERVAL=10 nvidia-power-tray

nvidia-power-tray --print prints <address> <state> once and exits without touching GTK — handy for testing or for a shell prompt/status bar.

Troubleshooting

systemctl --user status nvidia-power-tray.service
journalctl --user -u nvidia-power-tray.service -f

If the service runs but no icon appears, the AppIndicator extension is probably disabled: gnome-extensions list --enabled | grep appindicator.