Skip to content

Commit

Permalink
Lock stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
rodlie committed Feb 9, 2024
1 parent 407a44b commit cbb7d1d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/powerkit_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ void App::handlePrepareForResume()
{
qDebug() << "prepare for resume ...";
resetTimer();
ss->SimulateUserActivity();
ss->setDisplaysOff(false);
}

// turn off/on monitor using xrandr
Expand Down
2 changes: 2 additions & 0 deletions src/powerkit_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,8 @@ void Manager::LockScreen()
QProcess::startDetached(Settings::getValue(CONF_SCREENSAVER_LOCK_CMD,
PK_SCREENSAVER_LOCK_CMD).toString(),
QStringList());
QProcess::execute("xset",
QStringList() << "dpms" << "force" << "off");
}

bool Manager::HasBattery()
Expand Down
12 changes: 12 additions & 0 deletions src/powerkit_screensaver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ void ScreenSaver::Lock()
if (xlock.isEmpty()) { return; }
qDebug() << "screensaver lock";
QProcess::startDetached(xlock, QStringList());
setDisplaysOff(true);
}

void ScreenSaver::SimulateUserActivity()
Expand Down Expand Up @@ -206,3 +207,14 @@ const QString ScreenSaver::GetInternalDisplay()
XCloseDisplay(dpy);
return result;
}

void ScreenSaver::setDisplaysOff(bool off)
{
int xset = QProcess::execute("xset",
QStringList() << "dpms" << "force" << (off ? "off" : "on"));
if (!off) {
QProcess::execute("xset",
QStringList() << "s" << "reset");
}
qDebug() << "xset dpms force" << off << xset;
}
1 change: 1 addition & 0 deletions src/powerkit_screensaver.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ namespace PowerKit
void UnInhibit(quint32 cookie);
static const QMap<QString, bool> GetDisplays();
static const QString GetInternalDisplay();
static void setDisplaysOff(bool off);
};
}

Expand Down

0 comments on commit cbb7d1d

Please sign in to comment.