Skip to content

Commit

Permalink
Update config
Browse files Browse the repository at this point in the history
Add screen saver timeout (default 5min).
  • Loading branch information
rodlie committed Feb 9, 2024
1 parent cbb7d1d commit 86e5c8c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/powerkit_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,6 @@ namespace PowerKit
#define PK_SCREENSAVER_SERVICE "org.freedesktop.ScreenSaver"
#define PK_SCREENSAVER_PATH_ROOT "/ScreenSaver"
#define PK_SCREENSAVER_PATH_FULL "/org/freedesktop/ScreenSaver"
#define PK_SCREENSAVER_TIMEOUT_BLANK 300

#endif // POWERKIT_COMMON_H
24 changes: 23 additions & 1 deletion src/powerkit_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Dialog::Dialog(QWidget *parent,
, batteryStatusLabel(nullptr)
, cpuFreqLabel(nullptr)
, cpuTempLabel(nullptr)
, screensaverBlank(nullptr)
, hasCpuCoreTemp(false)
, hasBattery(false)
{
Expand Down Expand Up @@ -451,7 +452,18 @@ void Dialog::setupWidgets()
// screensaver
QGroupBox *ssContainer = new QGroupBox(this);
ssContainer->setTitle(tr("Screen saver"));
//QVBoxLayout *ssContainerLayout = new QVBoxLayout(ssContainer);
QHBoxLayout *ssContainerLayout = new QHBoxLayout(ssContainer);

const auto screensaverBlankLabel = new QLabel(tr("Timeout"), this);
screensaverBlank = new QSpinBox(this);
screensaverBlank->setMaximumWidth(MAX_WIDTH);
screensaverBlank->setMinimumWidth(MAX_WIDTH);
screensaverBlank->setMinimum(1);
screensaverBlank->setMaximum(1000);
screensaverBlank->setSuffix(QString(" %1").arg(tr("min")));

ssContainerLayout->addWidget(screensaverBlankLabel);
ssContainerLayout->addWidget(screensaverBlank);

// notify
QGroupBox *notifyContainer = new QGroupBox(this);
Expand Down Expand Up @@ -635,6 +647,8 @@ void Dialog::connectWidgets()
this, SLOT(handleNotifyNewInhibitor(bool)));
connect(backlightMouseWheel, SIGNAL(toggled(bool)),
this, SLOT(handleBacklightMouseWheel(bool)));
connect(screensaverBlank, SIGNAL(valueChanged(int)),
this, SLOT(handleScreensaverBlank(int)));
}

// load settings and set defaults
Expand Down Expand Up @@ -791,6 +805,9 @@ void Dialog::loadSettings()
enableLid(Client::lidIsPresent(dbus));
hasCpuCoreTemp = Cpu::hasCoreTemp();
if (!hasCpuCoreTemp) { cpuTempLabel->setVisible(false); }

screensaverBlank->setValue(Settings::getValue(CONF_SCREENSAVER_TIMEOUT_BLANK,
PK_SCREENSAVER_TIMEOUT_BLANK).toInt() / 60);
}

void Dialog::saveSettings()
Expand Down Expand Up @@ -1163,3 +1180,8 @@ void Dialog::handleBacklightMouseWheel(bool triggered)
{
Settings::setValue(CONF_BACKLIGHT_MOUSE_WHEEL, triggered);
}

void Dialog::handleScreensaverBlank(int value)
{
Settings::setValue(CONF_SCREENSAVER_TIMEOUT_BLANK, value * 60);
}
3 changes: 3 additions & 0 deletions src/powerkit_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ namespace PowerKit
QLabel *cpuFreqLabel;
QLabel *cpuTempLabel;

QSpinBox *screensaverBlank;

bool hasCpuCoreTemp;
bool hasBattery;

Expand Down Expand Up @@ -124,6 +126,7 @@ namespace PowerKit
void handleNotifyNewInhibitor(bool triggered);
void enableLid(bool enabled);
void handleBacklightMouseWheel(bool triggered);
void handleScreensaverBlank(int value);
};
}

Expand Down
2 changes: 0 additions & 2 deletions src/powerkit_screensaver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
#define PK_SCREENSAVER_TIMER 10000
#define PK_SCREENSAVER_MAX_INHIBIT 18000
#define PK_SCREENSAVER_ACTIVITY "SimulateUserActivity"
#define PK_SCREENSAVER_TIMEOUT_BLANK 300
#define PK_SCREENSAVER_TIMEOUT_LOCK 250

using namespace PowerKit;

Expand Down

0 comments on commit 86e5c8c

Please sign in to comment.