Skip to content
Permalink
Browse files

hotplug fixes

  • Loading branch information...
rodlie committed May 17, 2019
1 parent afe9fda commit 54a602beb3e86bb3ebebd0211dbe7372b208f0b0
Showing with 19 additions and 3 deletions.
  1. +2 −1 src/lib/power_def.h
  2. +17 −2 src/power/org.dracolinux.Power.Tray.cpp
@@ -62,7 +62,8 @@ enum criticalAction
#define TURN_OFF_MONITOR "xrandr --output %1 --off"
#define TURN_ON_MONITOR "xrandr --output %1 --auto "
#define LUMINA_XCONFIG "lumina-xconfig --reset-monitors"
#define DRACO_XCONFIG "draco-settings-x11 --reset-monitors"
#define DRACO_XCONFIG "draco-settings-x11"
#define DRACO_XCONFIG_RESET "draco-settings-x11 --reset-monitors"

#define LID_BATTERY_DEFAULT lidSleep
#define LID_AC_DEFAULT lidLock
@@ -543,7 +543,7 @@ void SysTray::loadSettings()
monitors.clear();
} else if (!wasHotplugOn && monitorHotplugSupport) { // turn on hotplug
qDebug() << "turn on monitor hotplug";
ht->requestSetScan(true);
ht->requestSetScan(false);
ht->requestScan();
handleFoundDisplays(Screens::outputs());
}
@@ -822,6 +822,8 @@ void SysTray::handleDisplay(const QString &display, bool connected)

bool wasConnected = monitors[display];
monitors[display] = connected;
bool turnOn = false;

if (wasConnected && !connected) {
// Turn off monitor using xrandr when disconnected.
qDebug() << "turn off monitor" << display;
@@ -834,9 +836,22 @@ void SysTray::handleDisplay(const QString &display, bool connected)
QProcess proc;
proc.start(QString(TURN_ON_MONITOR).arg(display));
proc.waitForFinished();
turnOn = true;
}
// load monitor settings
QProcess::startDetached(DRACO_XCONFIG);
QSettings xconfig(Draco::xconfigSettingsFile(), QSettings::IniFormat);
if (xconfig.allKeys().isEmpty()) {
QString cmd = "xrandr";
if (display != internalMonitor && turnOn) {
cmd.append(QString(" --output %1 --left-of %2")
.arg(display)
.arg(internalMonitor));
} else {
cmd.append(" --auto");
}
QProcess::startDetached(cmd);
}
else { QProcess::startDetached(DRACO_XCONFIG_RESET); }
}

void SysTray::handleFoundDisplays(QMap<QString, bool> displays)

0 comments on commit 54a602b

Please sign in to comment.
You can’t perform that action at this time.