OptimusUI
Optimus UI is a wrapper application written in python, libadwaita and GTK4 for prime-select. It's primary purpose is to provide one singular interface across many different linux distributions. Also it should be easy to install which is why it is shipped as a flatpak. This way users do not have to rely on their distribution maintainers to include a user interface to be used with prime-select.

In the past we also maintained a Gnome Extension but these are prone to break with every Gnome update. Therefore to lower the maintenance burden we've come to the conclusion to provide a singular application. Also to not need to fight distribution specific dependency changes or to rely on a distribution to ship certain libraries themselves we also made it a flatpak.
Arbitrary permissions
On flathub OptimusUI is marked as potentially unsafe which is true to some extend. Because OptimusUI has to access the hosts prime-select binary to trigger the switch of the GPU mode. For this it has to use flatpak-spawn --host
followed by either pkexec
or kdesu
to run prime-select
with superuser privileges. There currently is no other way to do this as flatpak does not allow for specifying a list of host binaries accessible to the sandbox.
While OptimusUI has the "power" to access anything on the host system we do not use this power outside the purpose of this application. You can also inspect the applications source code anytime here
Also OptimusUI uses this power to access /etc/os-release
of the host system. Because inside the flatpak sandbox this file will only give intel on the Flatpak runntime used. But depending on the host distributions the distribution provided prime-select has different capabilities. Therefore we need to check the actual distro to then determine which kind of prime-select is available and which features to expose in the user interface.
Limittations
While being a flatpak application OptimuUI comes with a few limitations. For OptimusUI to work the host system requires prime-select
, bbswtich
and the nvidia kernel module
all which can not be shipped via flatpak. These are dependencies which need to be provided by the target distribution themselves.
Supported Prime tools
Depending on the Linux distribution in use the actual package containing the prime-select
binary can be different. Currently OptimusUI has support for the following tools:
- SUSEPrime
- nvidia-prime
- fedora-prime-select
- nvidia-prime-select
Prime Features
If looking the the applications source code OptimusUI internally validates the running distribution and the used prime tool to determine which operating modes are available and thus exposes or hides away certain elements in the user interface.
SET_BOOT: The prime tool can set the operation mode to be applied on boot. Therefore on every reboot of the system this mode is restored.
- Only supported on SUSE and Debian based distributions
SET_OFFLOAD: Is a dedicated operating mode where both GPUs the iGPU and the dGPU are active and can be used simultaneously. Nvidia calls this PRIME Offloading
.
- Only supported on SUSE and Debian based distributions
- Works on Wayland and X11
SET_NVIDIA: Will make the nVidia (dGPU) the primary GPU and the integrated GPU will not be used.
- Supported on all distributions with a supported prime tool.
- Only works on X11
SET_INTEGRATED: Will make the iGPU the only active GPU and the nVidia GPU will be turned off if bbswitch is installed.
- Works on all distributions with a supported prime tool
- nVidia GPU will turn of on SUSE based distributions. If it also does on other distributions is unknown.
- Works on Wayland and X11
GET_CURRENT: Will allow OptimusUI to determine the currently active operating mode eg. nvidia, integrated or offload.
- Only works on SUSE and Debian based distributions
SERVICE: This prime feature is not yet implemented as only SUSE based distributions support this operation.
PRIME Offloading
If the system is in Offload
mode some can run an application on the nvidia GPU using the following environment varibales: __GLX_VENDOR_LIBRARY_NAME=nvidia __NV_PRIME_RENDER_OFFLOAD=1 __VK_LAYER_NV_optimus=NVIDIA_only
followed by the application to be run.
Note: Some distributions ship with switcherooctl
which at least on Gnome based desktop environments allows to run an application on the dedicated GPU by right-click an application launcher and choose Run with dedicated / integrated GPU
.
For *.desktop files to specify which is their prefered GPU some can add PrefersNonDefaultGPU=true
to the [Desktop Entry]
section. This will cause Gnome (and other switcheroo aware desktops) to run an application on the GPU which is not the currently active one. Usualyl the "NonDeffaultGPU" is the dedicated one. However if a system is running in Offload
mode and the GPU driving the displays is already the dGPU then the "NonDefaultGPU" will be the iGPU.
This can be an issue on desktops with integrated GPUs in their CPU but the user might not had disabled it via the BIOS and thus the iGPU is also available.
Without flatpak
While OptimusUI does some checks to determine if it is running inside or outside of flatpak this is not very well tested. But in theory should work. The reason for this is to allow for distributions to re-package the application without flaptak in mind. But distribution maintained packages are not supported by us. Therefore if you did not install OptimusUI from flathub and run into errors please make sure this does also apply to the flatpak release. Otherwise please file an issue to your distribution.
Test environments
OptimusUI has been tested on the following system configurations:
MSI CX61 0OD
- OS: Aeon, Kalpa
- Desktops: Gnome, KDE Plasma
- dGPU: nVidia GT 730M
- iGPU: Intel HD 4000
- nVidia Drivers: 470.256.02, 470.239.06
- Prime-Tool:
- SUSEPrime: 0.8.17, 0.8.18
- Linux Kernel: 6.xx
- Package format: Flatpak
When is OptimusUI / prime-select usefull?
- GPU based on Turing (GTX 16 / RTX 20 series) or Newer
- nvidia driver 435 or newer: NO
- nvidia driver older than 435: YES
- But the GPU will probably not work because earlier drivers might not have support for it anyway
- GPU based on Pascal (GTX 10 series) or earlier: YES
- This will require nVidia driver 390 or newer
- bbswitch is recommended to actually turn off the GPU if not in use as these and older GPUs lack the required power management features (e.g. GSP coprocessor)
- Open source nvidia drivers: NO
OptimusUI will evaluate most of these requirements on its own and notify the user. However, it does not validate the nvidia driver version as of now.
NOTICE: Depending on your distribution the package for prime-select might depend on further requirements not listed here
How does OptimusUI work
OptimusUI will do a brief system survey by this it checks the following things:
- If prime-select can be found in one of the following locations (escaping the sandbox using flatpak-spawn) following path:
/usr/bin/prime-select
/usr/sbin/prime-select
/bin/prime-select
/sbin/prime-select
Once a supported prime tool has be identified OptimusUI will then scan for compatible hardware with the pci vendor id 0x10DE
and device class 0x30000
(dekstop GPU) or 0x30200
(mobile GPU).
In the next step it will evaluate the device name using lspci -d 10DE:DEVICE_ID
.
Additionally OptimusUI will look for one of the following sudo tools pkexec
or kdesu
in order to show a graphical authentication dialog on the host system if prime-select
required superuser privileges.
Furthermore it does check the users host distribution by running flatpak-spawn --host cat /etc/os-release
and evaluate it's content.
Finally to use any prime-select feature it will escape the sandbox and run one of these commands depending on what the user clicked:
flatpak-spawn --host [pkexec/kdesu] (-c) prime-select (boot) [nvidia/intel/offload]
flatpak-spawn --host prime-select get-current
Sources
- Flathub: https://flathub.org/apps/de.z_ray.OptimusUI
- Source Code: https://codeberg.org/ZRayEntertainment/optimus-ui