diff --git a/CMakeLists.txt b/CMakeLists.txt index 12d5e87..2fb37cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,7 +120,7 @@ target_link_libraries(${PROJECT_NAME} Qt${QT_VERSION_MAJOR}::Widgets) # desktop files -configure_file(share/settings.desktop.in +configure_file(share/${PROJECT_NAME}.desktop ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.desktop @ONLY) diff --git a/share/autostart.desktop.in b/share/autostart.desktop.in deleted file mode 100644 index 38edc08..0000000 --- a/share/autostart.desktop.in +++ /dev/null @@ -1,9 +0,0 @@ -[Desktop Entry] -Name=PowerKit -Comment=Power Manager -Icon=ac-adapter -Exec=@PROJECT_NAME@ -Terminal=false -Type=Application -OnlyShowIn=Lumina;Draco; -StartupNotify=false diff --git a/share/conf.in b/share/conf.in deleted file mode 100644 index 5f14baa..0000000 --- a/share/conf.in +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/share/settings.desktop.in b/share/powerkit.desktop similarity index 100% rename from share/settings.desktop.in rename to share/powerkit.desktop diff --git a/share/powerkitd.8 b/share/powerkitd.8 deleted file mode 100644 index bf2111d..0000000 --- a/share/powerkitd.8 +++ /dev/null @@ -1,27 +0,0 @@ -.TH powerkitd 8 "PowerKit Documentation" -.SH NAME -powerkitd \- PowerKit Daemon -.SH SYNOPSIS -.B powerkitd -.SH "DESCRIPTION" -.PP -\fIpowerkitd\fR -provides the -\fIorg\&.freedesktop\&.PowerKit\fR -service on the system message bus\&. Users or administrators should never need to start this daemon as it will be automatically started by -\fBdbus-daemon\fR(1) -whenever an application calls into the -\fIorg\&.freedesktop\&.PowerKit\fR -service\&. -.SH "AUTHOR" -.PP -Written by Ole-André Rodlie -. -.SH "BUGS" -.PP -Please send bug reports to -\m[blue]\fB\%https://github.com/rodlie/powerkit/issues\fR\m[]. -.SH "SEE ALSO" -.PP -\fBpowerkit\fR(1), -\fBdbus-daemon\fR(1) diff --git a/share/service.in b/share/service.in deleted file mode 100644 index c73f9da..0000000 --- a/share/service.in +++ /dev/null @@ -1,4 +0,0 @@ -[D-BUS Service] -Name=@SERVICE_NAME@ -Exec=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/@PROJECT_NAME@d -User=@SERVICE_USER@ diff --git a/src/powerkit_rtc.cpp b/src/powerkit_rtc.cpp deleted file mode 100644 index 006fc08..0000000 --- a/src/powerkit_rtc.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* -# PowerKit -# CCopyright (c) Ole-André Rodlie All rights reserved. -# -# Available under the 3-clause BSD license -# See the LICENSE file for full details -*/ - -#include "powerkit_rtc.h" - -#ifdef Q_OS_LINUX -#include -#include -#include -#include -#include -#include -#define RTC_DEV "/dev/rtc" -#endif - -using namespace PowerKit; - -bool Rtc::setAlarm(const QDateTime &date) -{ -#ifdef Q_OS_LINUX - if (!date.isValid() || date.isNull()) { return false; } - - int fd, result = 0; - struct rtc_time rtc; - - fd = open(RTC_DEV, O_RDONLY); - if (fd == -1) { return false; } - - result = ioctl(fd, RTC_UIE_OFF, 0); - if (result == -1) { - close(fd); - return false; - } - - result = ioctl(fd, RTC_RD_TIME, &rtc); - if (result == -1) { - close(fd); - return false; - } - - rtc.tm_year = date.date().year(); - rtc.tm_mon = date.date().month(); - rtc.tm_mday = date.date().day(); - rtc.tm_hour = date.time().hour(); - rtc.tm_min = date.time().minute(); - rtc.tm_sec = date.time().second(); - - result = ioctl(fd, RTC_ALM_SET, &rtc); - if (result == -1) { - close(fd); - return false; - } - - result = ioctl(fd, RTC_AIE_ON, 0); - if (result == -1) { - close(fd); - return false; - } - - close(fd); - return true; -#else - Q_UNUSED(date) - return false; -#endif -} diff --git a/src/powerkit_rtc.h b/src/powerkit_rtc.h deleted file mode 100644 index 0c37a2f..0000000 --- a/src/powerkit_rtc.h +++ /dev/null @@ -1,23 +0,0 @@ -/* -# PowerKit -# CCopyright (c) Ole-André Rodlie All rights reserved. -# -# Available under the 3-clause BSD license -# See the LICENSE file for full details -*/ - -#ifndef POWERKIT_RTC_H -#define POWERKIT_RTC_H - -#include - -namespace PowerKit -{ - class Rtc - { - public: - static bool setAlarm(const QDateTime &date); - }; -} - -#endif // POWERKIT_RTC_H diff --git a/src/powerkitd.cpp b/src/powerkitd.cpp deleted file mode 100644 index 7bc978d..0000000 --- a/src/powerkitd.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* -# PowerKit -# CCopyright (c) Ole-André Rodlie All rights reserved. -# -# Available under the 3-clause BSD license -# See the LICENSE file for full details -*/ - -#include -#include - -#include "powerkitd_manager.h" - -#define DSERVICE "org.freedesktop.PowerKit" -#define DPATH "/PowerKit" -#define DFULL_PATH "/org/freedesktop/PowerKit" - -int main(int argc, char *argv[]) -{ - QCoreApplication a(argc, argv); - QCoreApplication::setOrganizationDomain("org"); - QCoreApplication::setApplicationName("freedesktop.PowerKit"); - - if (!QDBusConnection::systemBus().isConnected()) { - qWarning("Cannot connect to the D-Bus system bus."); - return 1; - } - - if (!QDBusConnection::systemBus().registerService(DSERVICE)) { - qWarning() << QDBusConnection::systemBus().lastError().message(); - return 1; - } - - Manager man; - if (!QDBusConnection::systemBus().registerObject(DPATH, - &man, - QDBusConnection::ExportAllContents)) { - qWarning() << QDBusConnection::systemBus().lastError().message(); - return 1; - } - if (!QDBusConnection::systemBus().registerObject(DFULL_PATH, - &man, - QDBusConnection::ExportAllContents)) { - qWarning() << QDBusConnection::systemBus().lastError().message(); - return 1; - } - - return a.exec(); -} diff --git a/src/powerkitd_manager.cpp b/src/powerkitd_manager.cpp deleted file mode 100644 index 25f12b6..0000000 --- a/src/powerkitd_manager.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* -# PowerKit -# CCopyright (c) Ole-André Rodlie All rights reserved. -# -# Available under the 3-clause BSD license -# See the LICENSE file for full details -*/ - -#include "powerkitd_manager.h" -#include "powerkit_rtc.h" -#include "powerkit_backlight.h" -#include "powerkit_cpu.h" - -#include - -Manager::Manager(QObject *parent) : QObject(parent) -{ -} - -bool Manager::SetWakeAlarm(const QString &alarm) -{ - qDebug() << "Try to set RTC wake alarm" << alarm; - QDateTime date = QDateTime::fromString(alarm, "yyyy-MM-dd HH:mm:ss"); - if (date.isNull() || !date.isValid()) { return false; } - return PowerKit::Rtc::setAlarm(date); -} - -bool Manager::SetDisplayBacklight(const QString &device, int value) -{ - qDebug() << "Try to set DISPLAY backlight" << device << value; - if (!PowerKit::Backlight::canAdjustBrightness(device)) { return false; } - int light = value; - if (light>PowerKit::Backlight::getMaxBrightness(device)) { light = PowerKit::Backlight::getMaxBrightness(device); } - else if (light<0) { light = 0; } - return PowerKit::Backlight::setCurrentBrightness(device, light); -} - -bool Manager::SetCpuGovernor(const QString &gov) -{ - qDebug() << "Try to set CPU governor" << gov; - return PowerKit::Cpu::setGovernor(gov); -} - -bool Manager::SetCpuFrequency(const QString &freq) -{ - qDebug() << "Try to set CPU frequency" << freq; - return PowerKit::Cpu::setFrequency(freq); -} - -bool Manager::SetPStateTurbo(bool enable) -{ - qDebug() << "Try to set Intel Turbo Boost" << enable; - return PowerKit::Cpu::setPStateTurbo(enable); -} - -bool Manager::SetPStateMax(int value) -{ - qDebug() << "Try to set Intel pstate max" << value; - return PowerKit::Cpu::setPStateMax(value); -} - -bool Manager::SetPStateMin(int value) -{ - qDebug() << "Try to set Intel pstate min" << value; - return PowerKit::Cpu::setPStateMin(value); -} - -bool Manager::SetPState(int min, int max) -{ - qDebug() << "Try to set Intel pstate min max" << min << max; - return PowerKit::Cpu::setPState(min, max); -} diff --git a/src/powerkitd_manager.h b/src/powerkitd_manager.h deleted file mode 100644 index c8962b4..0000000 --- a/src/powerkitd_manager.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -# PowerKit -# CCopyright (c) Ole-André Rodlie All rights reserved. -# -# Available under the 3-clause BSD license -# See the LICENSE file for full details -*/ - -#ifndef MANAGER_H -#define MANAGER_H - -#include -#include - -class Manager : public QObject -{ - Q_OBJECT - -public: - explicit Manager(QObject *parent = NULL); - -public slots: - bool SetWakeAlarm(const QString &alarm); - bool SetDisplayBacklight(const QString &device, int value); - bool SetCpuGovernor(const QString &gov); - bool SetCpuFrequency(const QString &freq); - bool SetPStateTurbo(bool enable); - bool SetPStateMax(int value); - bool SetPStateMin(int value); - bool SetPState(int min, int max); -}; - -#endif // MANAGER_H