8#include "gpudetection_p.h"
11#include <QDBusArgument>
12#include <QDBusConnection>
13#include <QDBusInterface>
15#include <QDBusVariant>
22static void checkGpu();
24static bool checkGpuWithSwitcheroo();
25static void checkGpuWithSolid();
33static GpuCheck s_gpuCheck = GpuCheck::NotChecked;
38 if (s_gpuCheck == GpuCheck::NotChecked) {
39 if (!checkGpuWithSwitcheroo()) {
45static bool checkGpuWithSwitcheroo()
48 QDBusInterface switcheroo(QStringLiteral(
"net.hadess.SwitcherooControl"),
49 QStringLiteral(
"/net/hadess/SwitcherooControl"),
50 QStringLiteral(
"org.freedesktop.DBus.Properties"),
52 if (!switcheroo.isValid()) {
56 QDBusReply<QDBusVariant> reply = switcheroo.call(QStringLiteral(
"Get"), QStringLiteral(
"net.hadess.SwitcherooControl"), QStringLiteral(
"GPUs"));
61 QDBusArgument arg = qvariant_cast<QDBusArgument>(reply.value().variant());
65 for (
const auto &gpu : gpus) {
66 bool defaultGpu = qvariant_cast<bool>(gpu[QStringLiteral(
"Default")]);
68 s_gpuCheck = GpuCheck::Present;
69 QStringList envList = qvariant_cast<QStringList>(gpu[QStringLiteral(
"Environment")]);
70 for (
int i = 0; i + 1 < envList.
size(); i += 2) {
71 s_gpuEnv.
insert(envList[i], envList[i + 1]);
79 s_gpuCheck = GpuCheck::Absent;
83static void checkGpuWithSolid()
87 QDBusInterface iface(QStringLiteral(
"org.kde.Solid.PowerManagement"),
88 QStringLiteral(
"/org/kde/Solid/PowerManagement"),
89 QStringLiteral(
"org.kde.Solid.PowerManagement"),
91 if (iface.isValid()) {
93 if (reply.
isValid() && reply.value()) {
94 s_gpuCheck = GpuCheck::Present;
95 s_gpuEnv.
insert(QStringLiteral(
"DRI_PRIME"), QStringLiteral(
"1"));
100 s_gpuCheck = GpuCheck::Absent;
110 return s_gpuCheck == GpuCheck::Present;
A namespace for KIO globals.
QDBusConnection sessionBus()
QDBusConnection systemBus()
bool isValid() const const
qsizetype size() const const
void insert(const QProcessEnvironment &e)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:58:45 by
doxygen 1.12.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.