Skip to content

Find discrete GPU using Switcheroo via environment instead of default flag

Jan Drögehoff requested to merge sentry/kio:switcheroo-nodefault-kf6 into master

The non default GPU in switcheroo is not always the discrete one, so instead of relying on the Default flag probe the environment.

In the output of lspci from various people I noticed the pattern that the iGPU tends to be on Bus 0, so we simply check if DRI_PRIME value starts with the relevant string.

Nvidia GPUs receive special treatment because Switcheroo does not give us the DRI_PRIME env var and because there no Nvidia iGPUs.

In the case there are multiple discrete GPUs in the system its checked if the Default GPU is discrete and use that.

For testing purposes I've also made a python script that has the same logic as this PR proposes as well as the original behavior that relies on the Default: https://gist.github.com/Jan200101/3424c20ea616f7b180e1724c602f1888 (if your PC does not have an iGPU and a dGPU thats default you can enable TEST_DATA)

Merge request reports

Loading