Adding upstream version 0.11.0.

upstream/0.11.0
Alf Gaida 8 years ago
parent b93e6cb5f4
commit 389781f911

4
.gitignore vendored

@ -0,0 +1,4 @@
build
nbproject
*kdev4*
*/translations/lxqt-powermanagement

@ -0,0 +1,218 @@
lxqt-powermanagement-0.11.0 / 2016-09-24
========================================
* README.md: Replace dependency XCB with KIdleTime
* Idleness Watcher: rely on KIdleTime instead of XCB (#33)
* fix indents
* Update and extend README.md
* Add Catalan translation
* Add Arabic Translation for Desktop File
* I18N: Fix Plural Strings (#38)
* Removes the QEventLoop from the Watcher class
* build: Use external translations
* ts-files removal (#34)
* Bump year Fix licenses, lxqt-powermanagement is LGPL only
* Fix source language in Italian translation file
* Italian translation update
* Update Russian translation Remove ru_RU files
* Fix typo in Greek translation
* update: lxqt-powermanagement_hu.ts
* Add German translation
0.10.0 / 2015-10-31
===================
* Update translations
* Fix LICENSE file
* Add (re)enabling info message
* Rename "On Ac" to "On AC" to have a single string for both
* Fix typo in message
* Remove "LXQt " from .desktop to follow pattern
* Update batteryhelper.cpp
* Fixed typo Unkown -> Unknown
* lidwatcher: don't listen to Changed signal
* Add some missing license headers
* OnlyShowIn=LXQt;
* Add Greek (el) translation Add the 'Comment' key in desktop file
* Add key "Comment" to desktop entry file
* Rename LxQt to LXQt everywhere
* Handles CMake policy CMP0063
* Use the LXQtCompilerSettings CMake module
* Make built-in icon move clockwise when charging
* Fix red-painting of built-in icon when power low
* Adds Runtime install COMPONENT
* Coding sytle change
* Use GNUInstallDirs
* Removes non existent RESOURCES
* Use CMAKE_AUTOUIC, drop qt5_wrap_ui()
* Remove unneeded include_directories() entries
* Minor strings update
* Updates the build system to the Targets infrastructure
* Remove trailing whitespaces
* Enable screen locking from the idleness watcher
* Prevent a too small value for the idle watcher
* Correctly check for batteries on first run
* re-add notification about missing battery
* Added italian translations
* Hungarian translations added
* Support CMake 2.8.11 again
* Typos: fix "Idle" capitalization and misspelling
* Add icons to the action in the systray icon's menu
* Polish translation updated
* Only show batteries of type PrimaryBattery. Fixes #535
* Make lxqt-powermanagement tray's tooltip work again
* Fix warning from clang
* Fix some wrong use of Solid::Battery::capacity instead of ..::energy
* Align slots and connects with what signals Solid offers
* Make batterywatcher react to energylevel- and powersupplystate changes
* Port to KF5's Solid
0.9.0 / 2015-01-26
==================
* Portuguese update
* Fix some translation keys
* Small layoutchange in batterysettings
* Fix strings to be easier translatable
* Portuguese update
* Add Japanese translation
* - Unify naming for a unique lxqt. No more suffixes
* Fix battery info dialog's layout
* Small tweak to the built-in icon
* Added semitransparent background to built in icon
* Simplified rendering of built-in icons and added a gradient to them
* Use SingleApplication rather than Application
* Handle more than one battery
* Reordered responsibillities between classes
* Some refactoring
* Some cleanup
* Remove cancel button from batteryinfodialog.ui
* Correct one fontsize in batteryinfo.ui
* Refactor battery info dialog to handle more than one battery
* Cleaned out a lot of old debug statements
* Adjusted how chargelevels are mapped to icons
* Added icon preview to batterywatcher config
* Factor out icon producing in separate class
* Clean up code for picking battery icon from theme
* Add icon to config window
* Fix config gui
* Use the new LXQtTranslate modules.
* Fixes translations not being loaded.
* Updates translations
* Adds and uses QtTranslate cmake module for handling .ts translations
* Add Russian translation
* Include Qt5Gui_PRIVATE_INCLUDE_DIRS for qplatformnativeinterface.h
* Clean up CMakeLists.txt, drop Qt4 support
* Adds option to disable systray icon in preferences and on the icon's context menu
0.8.0 / 2014-06-29
==================
* Fix incorrect lib linking.
* Add initial Qt5 support.
* Add missing lgpl-headers
* Recognize Alec Moskvin as author in 'about' dialog
* Fix includes, hopefuly correct this time
* Clean up includes
* Tell logind to not handle lidswitch when lidwatcher is enabled
* Added contextmenu to battery systemtray icon
* On first run disable lidwatcher/batterywatcher if lid/battery not present
* Add missing ${QTXDG_INCLUDE_DIRS} to include_directories().
* Use preferred header style
* Temporary fix for #86
* Corrected badly formed includes. Fix for #81
0.7.0 / 2014-05-01
==================
* Remove outdated and unused manpage
* Add AUTHORS
* Strings improvements
* Add CPack rules for creating tarball
* Fix .desktop icon (thanks, @agaida)
* Improvements to .desktop file
* Adapt to recent upower api changes
* Update README
* Fix updating of minutes and seconds in idleness settings
* Fix small bugs in idleness-settings, update of seconds
* Fix icons in configure-powermanager
* Slightly more userfriendly idleness-settings-dialog
* Added first-time-run notification with configure-button
* Some cleanup + fix idlenesswatcher to use power
* More code cleanup
* Minor adjustments to config ui's
* cleanup
* Code cleanup
* ui cleanups
* Clean up battery-watcher-settings ui
* Fixed lxqt-config-powermanagement.desktop file
* Renames and cleanup
* Lid, Idleness and Battery merged into one application
* Normalize imports
* Config for idleness and some more options for lidsettings
* Removed CMAKE_SOURCE_DIR usage from CMakeLists.txt files
* Fix renaming bugs, replacing lxqt-qt with lxde-qt
* Finish the crazy razor=>lxqt renaming tasks.
* rename razor to lxqt in some strings
* Replace lxqt with ${LXQT_LIBRARIES} when linking.
* Compile-time dependancy on lxqt library added
* Project name fixed
* Fix build and adopt new APIs of liblxqt.
* Renamed some #ifndef/#define s
* Make powermanagement compile and link with liblxqt and libqtxdg
* Changed prefix from lz to lxqt for all powermanagement apps
* Cleanup of old razor-autosuspend code
* cmake-files cleanup
* Initial commit
* Renames and cleanup in config
* Renames and cleanup in idleness
* Renames and cleanup in battery
* Rename and cleanup in lid
* Split razorautosuspend into lid and battery, make stuff compile
* Moved razorqt-screenlocker into razor-autosuspend
* X-RAZOR changed to Razor in desktop files
* razor-autosuspend handle more battery-icon naming schemes
* Fix underlinking with QtDbus
* Autosuspend: Force icon to update when settings change
* Autosuspend: Add config option to start/stop
* Autosuspend: Perform a first-run check for a battery
* Set battery info dialog title
* Trtanslations
* Fixes to razor-autosuspend trayicon drawing
* New, dynamically generated battery icon for razor-autosuspend
* preliminary manpages primary for razorqt and usefully in venenux
* autosuspend: fix discharging()
* Razor-autosuspend fix missing initialization of Battery
* Rename fields in razor-config-autosuspend to comply with code style
* Rename variables in razor-autosuspend to comply with coding standards
* Now possible to use theme-icons in razor-autosuspend
* Translations updated
* Translations updated
* first part of fixes based on Coverity Scan (code static analysis)
* Fix components missing translations
* Added copyright headers to constants.h, batteryinfo.h and batteryinfo.cpp in razor-autosuspend
* Typos found during translation
* Translations
* Delete bad en_GB translations
* Update translations
* Enable translations for some components that were missing them
* Load setting on startup and fix wrong slot
* razor-autosuspend watch for changes in settings
* Translations updated
* Removed line num from TS files.
* Make razorqt-autosuspend a module
* Generate translations for razorqt-autosuspend
* Use flexible layouts
* Translations
* Deleted old translation methods.
* New translation infrastructure
* Fixes in the debs files for the razor-config-autosuspend.desktop
* razor-autosuspend: When batteryinfo open it closes when trayicon clicked
* Detailed battery info when clicking razor-autosuspend tray icon
* razor-autosuspend registers as dbus-service (org.razor-qt.razor-autosuspend) - fixes #346
* Razor-autosuspend: power-low-level is now configurable
* Razor-autosuspend: Added shutdown as action on lidclosed or powerlow
* Added config app for razor-autosuspend
* Moved razor-autosuspend sourcefiles to src-dir
* Moved razor-autosuspend to toplevel as it is not really a part of razorqt-power

@ -1,4 +1,31 @@
lxqt-powermanagement
====================
# lxqt-powermanagement
Power management module for LXQt
## Overview
This repository is providing tools to monitor power management events and optionally trigger actions like e. g. shut down a system when laptop batteries are low on power.
The core components are two binaries `lxqt-powermanagement` and `lxqt-config-powermanagement`.
`lxqt-powermanagement` is running in a daemon-like manner as so-called "LXQt Module" and doing the actual work. GUI "Power Management Settings (binary `lxqt-config-powermanagement`) is used to customize settings.
Warning messages are displayed on the desktop by [lxqt-notificationd](https://github.com/lxde/lxqt-notificationd).
## Installation
### Compiling source code
Runtime dependencies are UPower, KIdleTime, qtsvg and [liblxqt](https://github.com/lxde/liblxqt).
Additional build dependencies are CMake and Solid, optionally Git to pull latest VCS checkouts. The localization files were outsourced to repository [lxqt-l10n](https://github.com/lxde/lxqt-l10n) so the corresponding dependencies are needed, too. Please refer to this repository's `README.md` for further information.
Code configuration is handled by CMake. CMake variable `CMAKE_INSTALL_PREFIX` has to be set to `/usr` on most operating systems.
To build run `make`, to install `make install` which accepts variable `DESTDIR` as usual.
### Binary packages
Official binary packages are provided by all major Linux distributions like Arch Linux, Debian (as of Debian stretch only), Fedora and openSUSE. Just use your package manager to search for string `lxqt-powermanagement`.
## Configuration, Usage
Daemon-like `lxqt-powermanagement` can be adjusted from section "Basic Settings" in configuration dialogue "LXQt Session Settings" (binary `lxqt-config-session`) of [lxqt-session](https://github.com/lxde/lxqt-session).
To customize settings there's configuration dialogue "Power Management Settings" (binary `lxqt-config-powermanagement`). It can be opened from the panel's main menu - Preferences - LXQt Settings - Power Management and is provided by the "Configuration Center" (binary `lxqt-config`) of [lxqt-config](https://github.com/lxde/lxqt-config) as well.

@ -0,0 +1,3 @@
Name[ar]=إدارة الطّاقة
GenericName[ar]=إعدادات إدارة الطّاقة
Comment[ar]=عدّة إعدادات لإدارة الطّاقة مثل مراقبات البطّاريّة أو الخمول

@ -0,0 +1,3 @@
Name[ca]=Gestió de l'energia
GenericName[ca]=Ajusts de la gestió de l'energia
Comment[ca]=Diversos ajusts pel que fa a la gestió de l'energia com la bateria o l'observador de l'ociositat

@ -15,7 +15,6 @@ set(SOURCES
powermanagementd.cpp
trayicon.cpp
iconproducer.cpp
x11helper.cpp
../config/powermanagementsettings.cpp
)
@ -28,12 +27,6 @@ set(DESKTOP_FILES_IN
lxqt-powermanagement.desktop.in
)
qt5_add_dbus_adaptor(SOURCES
org.freedesktop.ScreenSaver.xml
idlenesswatcher.h
IdlenessWatcher
)
lxqt_translate_ts(QM_FILES
UPDATE_TRANSLATIONS ${UPDATE_TRANSLATIONS}
SOURCES
@ -55,52 +48,10 @@ lxqt_translate_ts(QM_FILES
lxqt_app_translation_loader(lxqt-powermanagement_QM_LOADER ${PROJECT_NAME})
# XCB stuff (TODO: move into findXCB)
find_package(PkgConfig)
pkg_check_modules(PKG_XCB xcb)
find_path(XCB_INCLUDE_DIR xcb/xcb.h
${PKG_XCB_INCLUDE_DIRS}
)
find_library(XCB_LIBRARY NAMES xcb
PATHS
${PKG_XCB_LIBRARY_DIRS}
)
pkg_check_modules(PKG_X11_XCB x11-xcb)
find_path(X11_XCB_INCLUDE_DIR X11/Xlib-xcb.h
${PKG_X11_XCB_INCLUDE_DIRS}
)
find_library(X11_XCB_LIBRARY NAMES X11-xcb
PATHS
${PKG_X11_XCB_LIBRARY_DIRS}
)
pkg_check_modules(PKG_XCB_SCREENSAVER xcb-screensaver)
find_path(XCB_SCREENSAVER_INCLUDE_DIR xcb/screensaver.h
${PKG_XCB_SCREENSAVER_INCLUDE_DIRS}
)
find_library(XCB_SCREENSAVER_LIBRARY NAMES xcb-screensaver
PATHS
${PKG_XCB_SCREENSAVER_LIBRARY_DIRS}
)
pkg_check_modules(PKG_XCB_DPMS xcb-dpms)
find_path(XCB_DPMS_INCLUDE_DIR xcb/dpms.h
${PKG_XCB_SCREENSAVER_INCLUDE_DIRS}
)
find_library(XCB_DPMS_LIBRARY NAMES xcb-dpms
PATHS
${PKG_XCB_DPMS_LIBRARY_DIRS}
)
find_package(KF5IdleTime REQUIRED)
include_directories(
${Qt5Gui_PRIVATE_INCLUDE_DIRS}
${XCB_INCLUDE_DIR}
${X11_XCB_INCLUDE_DIR}
${XCB_SCREENSAVER_INCLUDE_DIR}
${XCB_DPMS_INCLUDE_DIR}
)
add_executable(lxqt-powermanagement
@ -114,11 +65,8 @@ add_executable(lxqt-powermanagement
target_link_libraries(lxqt-powermanagement
lxqt
${QTX_LIBRARIES}
${XCB_LIBRARY}
${XCB_SCREENSAVER_LIBRARY}
${XCB_DPMS_LIBRARY}
${X11_XCB_LIBRARY}
KF5::Solid
KF5::IdleTime
)
install(TARGETS

@ -183,18 +183,18 @@ QIcon IconProducer::buildCircleIcon(Solid::Battery::ChargeState state, int charg
if (chargeLevel > 99)
chargeLevel = 99;
double angle;
double angle;
QString sweepFlag;
if (state == Solid::Battery::Discharging)
{
angle = M_PI_2 + 2 * M_PI * chargeLevel/100;
sweepFlag = "0";
}
else
{
angle = M_PI_2 - 2 *M_PI * chargeLevel/100;
sweepFlag = "1";
}
if (state == Solid::Battery::Discharging)
{
angle = M_PI_2 + 2 * M_PI * chargeLevel/100;
sweepFlag = "0";
}
else
{
angle = M_PI_2 - 2 *M_PI * chargeLevel/100;
sweepFlag = "1";
}
double circle_endpoint_x = 80.0 * cos(angle) + 100;
double circle_endpoint_y = -80.0 * sin(angle) + 100;

@ -22,262 +22,46 @@
*
* END_COMMON_COPYRIGHT_HEADER */
#include <xcb/dpms.h>
#include <xcb/screensaver.h>
#include <QCoreApplication>
#include <QDebug>
#include <QDBusServiceWatcher>
#include <LXQt/ProgramFinder>
#include "screensaveradaptor.h"
#include "idlenesswatcher.h"
#include "x11helper.h"
/* lockers:
*
* xlock(more)
* i3lock -n
* slock
* alock
* xtrlock
*/
#include <QCoreApplication>
#include <KIdleTime>
#include <QDebug>
IdlenessWatcher::IdlenessWatcher(QObject* parent):
Watcher(parent),
mPSettings(),
mErrorNotification(tr("LXQt Idleness watcher failed to start")),
mDBusWatcher(this),
mInhibitorCookie(0),
mIsLocked(false)
Watcher(parent)
{
qDebug() << "Starting idlenesswatcher";
mConn = X11Helper::connection();
xcb_prefetch_extension_data(mConn, &xcb_screensaver_id);
xcb_prefetch_extension_data(mConn, &xcb_dpms_id);
xcb_screensaver_query_version_cookie_t verCookie = xcb_screensaver_query_version_unchecked(mConn, XCB_SCREENSAVER_MAJOR_VERSION, XCB_SCREENSAVER_MINOR_VERSION);
xcb_dpms_get_version_cookie_t dpmsVerCookie = xcb_dpms_get_version_unchecked(mConn, XCB_DPMS_MAJOR_VERSION, XCB_DPMS_MINOR_VERSION);
// Note that XCB is asynchronous, so we want to make requests ASAP and get the responses as late as possible.
mScreen = screenOfDisplay(mConn, 0);
mErrorNotification.setUrgencyHint(LXQt::Notification::UrgencyCritical);
mErrorNotification.setIcon("object-unlocked");
mErrorNotification.setTimeout(0);
new ScreenSaverAdaptor(this);
QDBusConnection sessionBus = QDBusConnection::sessionBus();
if (!sessionBus.registerService("org.freedesktop.ScreenSaver")
|| !sessionBus.registerObject("/ScreenSaver", this))
{
mErrorNotification.setBody(tr("D-Bus interface org.freedesktop.ScreenSaver is already registered"));
mErrorNotification.update();
qWarning() << "ERROR: D-Bus interface org.freedesktop.ScreenSaver is already registered";
}
mDBusWatcher.setConnection(QDBusConnection::sessionBus());
mDBusWatcher.setWatchMode(QDBusServiceWatcher::WatchForUnregistration);
connect(&mTimer, SIGNAL(timeout()), SLOT(idleTimeout()));
connect(&mPSettings, SIGNAL(settingsChanged()), SLOT(restartTimer()));
connect(this, SIGNAL(done()), this, SLOT(restartTimer()));
connect(&mDBusWatcher, SIGNAL(serviceUnregistered(QString)), SLOT(serviceUnregistered(QString)));
connect(&mLockProcess, SIGNAL(finished(int,QProcess::ExitStatus)), SLOT(screenUnlocked(int,QProcess::ExitStatus)));
connect(&mErrorNotification, SIGNAL(actionActivated(int)), SLOT(notificationAction(int)));
// Get XCB responses ...
const xcb_query_extension_reply_t* extReply = xcb_get_extension_data(mConn, &xcb_screensaver_id);
const xcb_query_extension_reply_t* dpmsExtReply = xcb_get_extension_data(mConn, &xcb_dpms_id);
xcb_screensaver_query_version_reply_t* verReply = xcb_screensaver_query_version_reply(mConn, verCookie, NULL);
xcb_dpms_get_version_reply_t* dpmsVerReply = xcb_dpms_get_version_reply(mConn, dpmsVerCookie, NULL);
if (mScreen && extReply && extReply->present && dpmsExtReply && dpmsExtReply->present
&& verReply && dpmsVerReply
&& verReply->server_major_version == XCB_SCREENSAVER_MAJOR_VERSION
&& verReply->server_minor_version >= XCB_SCREENSAVER_MINOR_VERSION
//&& dpmsVerReply->server_major_version == XCB_DPMS_MAJOR_VERSION
//&& dpmsVerReply->server_minor_version >= XCB_DPMS_MINOR_VERSION
)
{
free(verReply);
free(dpmsVerReply);
}
else
{
mErrorNotification.setBody(tr("The X11 Screensaver extension is not usable"));
mErrorNotification.update();
if (verReply)
free(verReply);
qCritical() << "ERROR: Can't use the X11 Screensaver Extension!";
}
mErrorNotification.setActions(QStringList(tr("Configure...")));
qDebug() << "LXQt Screenlocker started.";
qDebug() << "timeout:" << getMaxIdleTimeoutMs() << "ms, lock command:" << mLockCommand;
restartTimer();
}
xcb_screen_t* IdlenessWatcher::screenOfDisplay(xcb_connection_t* conn, int screen)
{
xcb_screen_iterator_t iter = xcb_setup_roots_iterator(xcb_get_setup(conn));
for (; iter.rem; --screen, xcb_screen_next(&iter))
if (screen == 0)
return iter.data;
return NULL;
}
uint IdlenessWatcher::getIdleTimeMs()
{
xcb_screensaver_query_info_cookie_t infoCookie = xcb_screensaver_query_info_unchecked(mConn, mScreen->root);
xcb_screensaver_query_info_reply_t* infoReply = xcb_screensaver_query_info_reply(mConn, infoCookie, NULL);
if (!infoReply)
{
qWarning() << "Bad reply from X11 Screensaver";
return 0;
}
uint msSinceUserInput = infoReply->ms_since_user_input;
free(infoReply);
return msSinceUserInput;
}
uint IdlenessWatcher::getMaxIdleTimeoutMs()
{
return 1000 * mPSettings.getIdlenessTimeSecs();
}
void IdlenessWatcher::idleTimeout()
{
uint msSinceUserInput = getIdleTimeMs();
if (msSinceUserInput >= getMaxIdleTimeoutMs())
{
mTimer.stop();
doAction(mPSettings.getIdlenessAction());
}
else
mTimer.start(getMaxIdleTimeoutMs() - msSinceUserInput);
}
void IdlenessWatcher::restartTimer()
{
qDebug() << ">>> Timer Restarted, waiting: " << getMaxIdleTimeoutMs() << "msecs";
mTimer.start(getMaxIdleTimeoutMs());
}
void IdlenessWatcher::screenUnlocked(int exitCode, QProcess::ExitStatus exitStatus)
{
mIsLocked = false;
emit ActiveChanged(false);
if (exitCode == 0)
{
restartTimer();
}
else
{
mErrorNotification.setSummary(tr("ERROR: Screen unlocked"));
if (exitStatus == QProcess::NormalExit)
mErrorNotification.setBody(tr("Locking program \"%1\" exited with error code %2").arg(mLockCommand).arg(exitCode));
else
mErrorNotification.setBody(tr("Locking program \"%1\" crashed with error code %2").arg(mLockCommand).arg(exitCode));
mErrorNotification.update();
mTimer.stop();
connect(&mErrorNotification, SIGNAL(notificationClosed(CloseReason)), SLOT(idleTimeout()));
}
}
void IdlenessWatcher::notificationAction(int num)
{
switch (num)
{
case 0: // "Configure"
QProcess::startDetached("lxqt-config-screenlocker");
}
}
void IdlenessWatcher::serviceUnregistered(const QString& service)
{
for (QMutableMapIterator<uint, QString> iter(mInhibitors); iter.hasNext();)
{
if (iter.next().value() == service)
{
qDebug() << "Service unregistered:" << iter.value();
mDBusWatcher.removeWatchedService(iter.value());
iter.remove();
}
}
if (mInhibitors.isEmpty())
restartTimer();
}
/* ---------- D-Bus methods ---------- */
void IdlenessWatcher::Lock()
{
// lockScreen();
}
uint IdlenessWatcher::GetSessionIdleTime()
{
return getIdleTimeMs() / 1000;
}
connect(KIdleTime::instance(),
static_cast<void (KIdleTime::*)(int)>(&KIdleTime::timeoutReached),
this,
&IdlenessWatcher::timeoutReached);
uint IdlenessWatcher::GetActiveTime()
{
if (!mIsLocked)
return 0;
return mLockTime.secsTo(QDateTime::currentDateTime());
}
connect(&mPSettings, &LXQt::Settings::settingsChanged,
this, &IdlenessWatcher::onSettingsChanged);
bool IdlenessWatcher::GetActive()
{
return mIsLocked;
setup();
}
bool IdlenessWatcher::SetActive(bool activate)
IdlenessWatcher::~IdlenessWatcher()
{
//if (!activate)
return false;
//return lockScreen();
KIdleTime::instance()->removeAllIdleTimeouts();
}
void IdlenessWatcher::SimulateUserActivity()
void IdlenessWatcher::setup()
{
restartTimer();
}
uint IdlenessWatcher::Inhibit(const QString& applicationName, const QString& reasonForInhibit)
{
mInhibitorCookie++;
QString service(this->message().service());
qDebug() << "*** Inhibit by" << applicationName << ":" << reasonForInhibit << ". Service:" << service << "->" << mInhibitorCookie;
mDBusWatcher.addWatchedService(service);
qDebug() << mDBusWatcher.watchedServices();
mInhibitors.insert(mInhibitorCookie, service);
mTimer.stop();
return mInhibitorCookie;
}
void IdlenessWatcher::UnInhibit(uint cookie)
{
qDebug() << "*** Uninhibit" << cookie;
mDBusWatcher.removeWatchedService(mInhibitors.value(cookie));
mInhibitors.remove(cookie);
if (mInhibitors.isEmpty())
restartTimer();
int timeout = 1000 * mPSettings.getIdlenessTimeSecs();
KIdleTime::instance()->addIdleTimeout(timeout);
}
uint IdlenessWatcher::Throttle(const QString& applicationName, const QString& reasonForThrottle)
void IdlenessWatcher::timeoutReached(int identifier)
{
Q_UNUSED(applicationName);
Q_UNUSED(reasonForThrottle);
return 0;
doAction(mPSettings.getIdlenessAction());
}
void IdlenessWatcher::UnThrottle(uint cookie)
void IdlenessWatcher::onSettingsChanged()
{
Q_UNUSED(cookie);
KIdleTime::instance()->removeAllIdleTimeouts();
setup();
}

@ -25,67 +25,24 @@
#ifndef IDLENESSWATCHER_H
#define IDLENESSWATCHER_H
#include <xcb/xcb.h>
#include <QMap>
#include <QTimer>
#include <QProcess>
#include <QDateTime>
#include <QDBusContext>
#include <QDBusServiceWatcher>
#include <LXQt/Settings>
#include <LXQt/Notification>
#include "../config/powermanagementsettings.h"
#include "watcher.h"
class IdlenessWatcher : public Watcher, protected QDBusContext
class IdlenessWatcher : public Watcher
{
Q_OBJECT
public:
explicit IdlenessWatcher(QObject* parent = 0);
signals:
void ActiveChanged(bool in0);
public slots:
void Lock();
uint GetSessionIdleTime();
uint GetActiveTime();
bool GetActive();
bool SetActive(bool activate);
void SimulateUserActivity();
uint Inhibit(const QString& applicationName, const QString& reasonForInhibit);
void UnInhibit(uint cookie);
uint Throttle(const QString& applicationName, const QString& reasonForThrottle);
void UnThrottle(uint cookie);
virtual ~IdlenessWatcher();
private slots:
void idleTimeout();
void screenUnlocked(int exitCode, QProcess::ExitStatus exitStatus);
void notificationAction(int num);
void serviceUnregistered(const QString& service);
void restartTimer();
void setup();
void timeoutReached(int identifier);
void onSettingsChanged();
private:
uint getIdleTimeMs();
uint getMaxIdleTimeoutMs();
static xcb_screen_t* screenOfDisplay(xcb_connection_t* mConn, int screen);
PowerManagementSettings mPSettings;
QTimer mTimer;
QProcess mLockProcess;
LXQt::Notification mErrorNotification;
QString mLockCommand;
QDateTime mLockTime;
QMap<uint,QString> mInhibitors;
QDBusServiceWatcher mDBusWatcher;
xcb_connection_t* mConn;
xcb_screen_t* mScreen;
uint mInhibitorCookie;
bool mIsLocked;
bool mTurnOffDisplay;
};
#endif // IDLENESSWATCHER_H

@ -1,42 +0,0 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.freedesktop.ScreenSaver">
<signal name="ActiveChanged">
<arg type="b"/>
</signal>
<method name="Lock">
</method>
<method name="SimulateUserActivity">
</method>
<method name="GetActive">
<arg type="b" direction="out"/>
</method>
<method name="GetActiveTime">
<arg name="seconds" type="u" direction="out"/>
</method>
<method name="GetSessionIdleTime">
<arg name="seconds" type="u" direction="out"/>
</method>
<method name="SetActive">
<arg type="b" direction="out"/>
<arg name="e" type="b" direction="in"/>
</method>
<method name="Inhibit">
<arg name="application_name" type="s" direction="in"/>
<arg name="reason_for_inhibit" type="s" direction="in"/>
<arg name="cookie" type="u" direction="out"/>
</method>
<method name="UnInhibit">
<arg name="cookie" type="u" direction="in"/>
</method>
<method name="Throttle">
<arg name="application_name" type="s" direction="in"/>
<arg name="reason_for_throttle" type="s" direction="in"/>
<arg name="cookie" type="u" direction="out"/>
</method>
<method name="UnThrottle">
<arg name="cookie" type="u" direction="in"/>
</method>
</interface>
</node>

@ -25,6 +25,7 @@
#include <QDebug>
#include <QStringList>
#include <QProcess>
#include "batteryhelper.h"
#include "powermanagementd.h"

@ -1,42 +0,0 @@
/* BEGIN_COMMON_COPYRIGHT_HEADER
* (c)LGPL2+
*
* LXDE-Qt - a lightweight, Qt based, desktop toolset
* http://razor-qt.org
*
* Copyright (C) 2012 Alec Moskvin <alecm@gmx.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* END_COMMON_COPYRIGHT_HEADER */
#include "x11helper.h"
#include <QtGui/QGuiApplication>
#include <qpa/qplatformnativeinterface.h>
Display* X11Helper::display()
{
QPlatformNativeInterface *native = qApp->platformNativeInterface();
void* display = native->nativeResourceForWindow("display", 0);
return reinterpret_cast<Display*>(display);
}
xcb_connection_t* X11Helper::connection()
{
QPlatformNativeInterface *native = qApp->platformNativeInterface();
void* connection = native->nativeResourceForWindow("connection", 0);
return reinterpret_cast<xcb_connection_t*>(connection);
}

@ -1,54 +0,0 @@
/* BEGIN_COMMON_COPYRIGHT_HEADER
* (c)LGPL2+
*
* LXDE-Qt - a lightweight, Qt based, desktop toolset
* http://razor-qt.org
*
* Copyright (C) 2013 Alec Moskvin <alecm@gmx.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* END_COMMON_COPYRIGHT_HEADER */
#ifndef X11HELPER_H
#define X11HELPER_H
#include <xcb/xcb.h>
// Avoid polluting everything with X11/Xlib.h:
typedef struct _XDisplay Display;
/**
* @brief The X11Helper class is class to get the X11 Display or XCB connection
*
* It's intended to be used as a wrapper/replacement for QX11Info, which is removed in Qt5.
*/
class X11Helper
{
public:
/**
* @brief display Returns the X11 display
* @return
*/
static Display* display();
/**
* @brief connection Returns the XCB connection
* @return
*/
static xcb_connection_t* connection();
};
#endif // X11HELPER_H
Loading…
Cancel
Save