Commit 597e826c authored by Sebastian Kügler's avatar Sebastian Kügler
Browse files

Load a fixed screen configuration if configured

With this patch, kscreen will prefer a file called fixed-config from
~/.local/share/kscreen if it exists. The idea is that a user (let's
call him Ben) can force a configuration to be loaded even if the
hardware is a bit wonky (or, complex).

Specifically, this makes the UTS data arena more workable even when
screens come and go accidentally, the configuration won't be changed
to something entirely made up but mostly be kept intact. With setups
with lots of screens this can easily happen when some scientist walks
over a cable while being in some kind of virtual reality. (It
happens to me literally all the time).

We've been testing this feature for over a year, I'm merging it now
since it makes the lives of one of our high-profile users a lot
easier, so as a maintainer I'm fine with bearing the costs of this
additional code-path, just in this case.
parent 58f9e46b
......@@ -36,7 +36,7 @@
#include <kscreen/edid.h>
QString Serializer::sConfigPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) % QStringLiteral("/kscreen/");
QString Serializer::sFixedConfig = QStringLiteral("fixed-config");
void Serializer::setConfigPath(const QString &path)
sConfigPath = path;
......@@ -86,16 +86,22 @@ bool Serializer::configExists(const KScreen::ConfigPtr &config)
bool Serializer::configExists(const QString &id)
return QFile::exists(sConfigPath % id);
return (QFile::exists(sConfigPath % id) || QFile::exists(sConfigPath % sFixedConfig));
KScreen::ConfigPtr Serializer::config(const KScreen::ConfigPtr &currentConfig, const QString &id)
KScreen::ConfigPtr config = currentConfig->clone();
QFile file(configFileName(id));
QFile file;
if (QFile::exists(sConfigPath % sFixedConfig)) {
file.setFileName(sConfigPath % sFixedConfig);
qCDebug(KSCREEN_KDED) << "found a fixed config, will use " << file.fileName();
} else {
if (! {
qCDebug(KSCREEN_KDED) << "failed to open file" << id;
qCDebug(KSCREEN_KDED) << "failed to open file" << file.fileName();
return KScreen::ConfigPtr();
......@@ -45,6 +45,7 @@ private:
static QString configFileName(const QString &configId);
static QString sConfigPath;
static QString sFixedConfig;
......@@ -47,6 +47,7 @@ private Q_SLOTS:
void testNullConfig();
void testIdenticalOutputs();
void testMoveConfig();
void testFixedConfig();
KScreen::ConfigPtr createConfig(bool output1Connected, bool output2Conected);
......@@ -459,6 +460,25 @@ void TestSerializer::testMoveConfig()
Serializer::setConfigPath(QStringLiteral(TEST_DATA "/serializerdata/"));
void TestSerializer::testFixedConfig()
// Load a dualhead config
KScreen::ConfigPtr config = createConfig(true, true);
config = Serializer::config(config, QStringLiteral("twoScreenConfig.json"));
// Make sure we don't write into TEST_DATA
Serializer::setConfigPath(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) % QStringLiteral("/kscreen/"));
// save config as the current one, this is the config we don't want restored, and which we'll overwrite
Serializer::saveConfig(config, Serializer::sFixedConfig);
// Check if both files exist
QFile fixedCfg(Serializer::configFileName(Serializer::sFixedConfig));
#include "serializertest.moc"
\ No newline at end of file
#include "serializertest.moc"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment