summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2020-06-22 16:03:31 +0200
committerSimon Rettberg2020-06-22 16:03:31 +0200
commit74c8f847cafa4c47b89688b3808a66ba396aeeb7 (patch)
tree1954ef48894ccad43e528ba1d8e2659bac55c984
parentMake detection of virtual screen smarter; fall back to disconnected (diff)
downloadslxgreeter-74c8f847cafa4c47b89688b3808a66ba396aeeb7.tar.gz
slxgreeter-74c8f847cafa4c47b89688b3808a66ba396aeeb7.tar.xz
slxgreeter-74c8f847cafa4c47b89688b3808a66ba396aeeb7.zip
Disable ALL outputs if setting resolution fails
NVIDIA cards don't allow setting any resolution on disconnected screens. Simply disable all outputs in that case and set the screen size manually.
-rw-r--r--src/loginrpc.cpp30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/loginrpc.cpp b/src/loginrpc.cpp
index 6ad70ec..bbb1e1d 100644
--- a/src/loginrpc.cpp
+++ b/src/loginrpc.cpp
@@ -72,14 +72,15 @@ void LoginRpc::handleCommandV1(const QString &command)
p.start("xrandr");
p.waitForFinished(2000);
QString out = QString::fromLocal8Bit(p.readAll());
- QRegularExpression re("^(\\S+)\\s.*?(\\w+connected)", QRegularExpression::MultilineOption);
+ QRegularExpression re("^(\\S+)\\s.*?(\\w*connected)", QRegularExpression::MultilineOption);
QRegularExpressionMatchIterator it = re.globalMatch(out);
QString disconnectedOut;
QString virtOut;
- QStringList outputs;
+ QStringList disabledOutputs, allOutputs;
while (it.hasNext()) {
QRegularExpressionMatch m = it.next();
QString output = m.captured(1);
+ allOutputs << output;
if (virtOut.isEmpty() && (output == QLatin1String("VIRTUAL1") || output == QLatin1String("VIRTUAL-1")
|| output == QLatin1String("Virtual1") || output == QLatin1String("Virtual-1")
|| output == QLatin1String("default"))) {
@@ -87,7 +88,7 @@ void LoginRpc::handleCommandV1(const QString &command)
} else if (disconnectedOut.isEmpty() && m.captured(2) == "disconnected") {
disconnectedOut = output;
} else {
- outputs << output;
+ disabledOutputs << output;
}
}
if (virtOut.isEmpty() && !disconnectedOut.isEmpty()) {
@@ -95,16 +96,16 @@ void LoginRpc::handleCommandV1(const QString &command)
disconnectedOut.clear();
}
if (!disconnectedOut.isEmpty()) {
- outputs << disconnectedOut;
+ disabledOutputs << disconnectedOut;
}
- if (virtOut.isEmpty() && !outputs.isEmpty()) {
- virtOut = outputs.takeFirst();
+ if (virtOut.isEmpty() && !disabledOutputs.isEmpty()) {
+ virtOut = disabledOutputs.takeFirst();
}
- qDebug() << "Virtual output:" << virtOut << "unwanted additional outputs:" << outputs << "(First disconnected:" << disconnectedOut << ")";
+ qDebug() << "Virtual output:" << virtOut << "unwanted additional outputs:" << disabledOutputs << "(First disconnected:" << disconnectedOut << ")";
p.kill();
if (!virtOut.isEmpty()) {
setMode << "--output" << virtOut << "--mode" << name;
- for (auto output : outputs) {
+ for (auto output : disabledOutputs) {
setMode << "--output" << output << "--off";
}
qDebug() << "Setting mode" << newmode;
@@ -120,7 +121,20 @@ void LoginRpc::handleCommandV1(const QString &command)
// Set all outputs
p.start("xrandr", setMode);
p.waitForFinished(2000);
+ int ret = p.exitCode();
p.kill();
+ if (ret != 0) {
+ // Play it safe and disable all the outputs
+ qDebug() << "Command failed, trying to disable all outputs";
+ setMode.clear();
+ setMode << "--verbose" << "--fb" << name;
+ for (auto s : allOutputs) {
+ setMode << "--output" << s << "--off";
+ }
+ p.start("xrandr", setMode);
+ p.waitForFinished(2000);
+ p.kill();
+ }
}
}
}