diff --git a/src/powerkit.cpp b/src/powerkit.cpp index 7de32ae..2af0750 100644 --- a/src/powerkit.cpp +++ b/src/powerkit.cpp @@ -46,8 +46,8 @@ int main(int argc, char *argv[]) return a.exec(); } else if (setBrightness) { int val = PowerKit::Backlight::getCurrentBrightness(); - if (args.contains(CMD_OPT_BRIGHTNESS_UP)) { val += BACKLIGHT_MOVE_VALUE; } - else if (args.contains(CMD_OPT_BRIGHTNESS_DOWN)) { val -= BACKLIGHT_MOVE_VALUE; } + if (args.contains(CMD_OPT_BRIGHTNESS_UP)) { val += POWERKIT_BACKLIGHT_STEP; } + else if (args.contains(CMD_OPT_BRIGHTNESS_DOWN)) { val -= POWERKIT_BACKLIGHT_STEP; } return PowerKit::Backlight::setBrightness(val); } else if (setSleep || setHibernate || setLock) { QDBusInterface manager(POWERKIT_SERVICE, diff --git a/src/powerkit_app.cpp b/src/powerkit_app.cpp index bc5abfd..3baafa5 100644 --- a/src/powerkit_app.cpp +++ b/src/powerkit_app.cpp @@ -25,6 +25,17 @@ #define VIRTUAL_MONITOR "VIRTUAL" +#define PK_SCREENSAVER_SERVICE "org.freedesktop.ScreenSaver" +#define PK_SCREENSAVER_PATH_ROOT "/ScreenSaver" +#define PK_SCREENSAVER_PATH_FULL "/org/freedesktop/ScreenSaver" + +#define PM_SERVICE_INHIBIT "org.freedesktop.PowerManagement.Inhibit" +#define PM_FULL_PATH_INHIBIT "/org/freedesktop/PowerManagement/Inhibit" + +#define PM_SERVICE "org.freedesktop.PowerManagement" +#define PM_FULL_PATH "/org/freedesktop/PowerManagement" +#define POWERKIT_FULL_PATH "/org/freedesktop/PowerKit" + using namespace PowerKit; App::App(QObject *parent) @@ -35,21 +46,21 @@ App::App(QObject *parent) , ss(nullptr) , wasLowBattery(false) , wasVeryLowBattery(false) - , lowBatteryValue(LOW_BATTERY) - , critBatteryValue(CRITICAL_BATTERY) + , lowBatteryValue(POWERKIT_LOW_BATTERY) + , critBatteryValue(POWERKIT_CRITICAL_BATTERY) , hasService(false) - , lidActionBattery(LID_BATTERY_DEFAULT) - , lidActionAC(LID_AC_DEFAULT) - , criticalAction(CRITICAL_DEFAULT) - , autoSuspendBattery(AUTO_SLEEP_BATTERY) + , lidActionBattery(POWERKIT_LID_BATTERY_ACTION) + , lidActionAC(POWERKIT_LID_AC_ACTION) + , criticalAction(POWERKIT_CRITICAL_ACTION) + , autoSuspendBattery(POWERKIT_AUTO_SLEEP_BATTERY) , autoSuspendAC(0) , timer(nullptr) , timeouts(0) , showNotifications(true) , showTray(true) , disableLidOnExternalMonitors(false) - , autoSuspendBatteryAction(suspendSleep) - , autoSuspendACAction(suspendNone) + , autoSuspendBatteryAction(POWERKIT_SUSPEND_BATTERY_ACTION) + , autoSuspendACAction(POWERKIT_SUSPEND_AC_ACTION) , watcher(nullptr) , lidXrandr(false) , lidWasClosed(false) @@ -188,7 +199,7 @@ App::App(QObject *parent) Theme::setAppTheme(); Theme::setIconTheme(); if (tray->icon().isNull()) { - tray->setIcon(QIcon::fromTheme(DEFAULT_AC_ICON)); + tray->setIcon(QIcon::fromTheme(POWERKIT_ICON)); } loadSettings(); @@ -590,11 +601,6 @@ void App::drawBattery(double left) !tray->isVisible() && showTray) { tray->show(); } - if (!man->HasBattery()) { - tray->setIcon(QIcon::fromTheme(DEFAULT_AC_ICON)); - return; - } - QColor colorBg = Qt::green; QColor colorFg = Qt::white; int pixelSize = 22; @@ -605,7 +611,8 @@ void App::drawBattery(double left) colorBg = Qt::red; } } else { - if (left == 100) { colorFg = Qt::green; } + if (!man->HasBattery()) { left = 100; } + else if (left == 100) { colorFg = Qt::green; } } tray->setIcon(Theme::drawCircleProgress(left, @@ -903,11 +910,11 @@ void App::handleTrayWheel(TrayIcon::WheelAction action) switch (action) { case TrayIcon::WheelUp: Backlight::setBrightness(backlightDevice, - Backlight::getCurrentBrightness(backlightDevice)+BACKLIGHT_MOVE_VALUE); + Backlight::getCurrentBrightness(backlightDevice)+POWERKIT_BACKLIGHT_STEP); break; case TrayIcon::WheelDown: Backlight::setBrightness(backlightDevice, - Backlight::getCurrentBrightness(backlightDevice)-BACKLIGHT_MOVE_VALUE); + Backlight::getCurrentBrightness(backlightDevice)-POWERKIT_BACKLIGHT_STEP); break; default:; } diff --git a/src/powerkit_backlight.cpp b/src/powerkit_backlight.cpp index 9aa5189..99a5b85 100644 --- a/src/powerkit_backlight.cpp +++ b/src/powerkit_backlight.cpp @@ -106,7 +106,7 @@ bool Backlight::setCurrentBrightness(int value) bool Backlight::setBrightness(const QString &device, int value) { - QDBusInterface iface(LOGIND_SERVICE, + QDBusInterface iface(POWERKIT_LOGIND_SERVICE, LOGIND_PATH_SESSION, LOGIND_SESSION, QDBusConnection::systemBus()); diff --git a/src/powerkit_common.h b/src/powerkit_common.h index 0d78921..4586d26 100644 --- a/src/powerkit_common.h +++ b/src/powerkit_common.h @@ -51,115 +51,24 @@ namespace PowerKit }; } -#define LID_BATTERY_DEFAULT PowerKit::lidSleep -#define LID_AC_DEFAULT PowerKit::lidLock -#define CRITICAL_DEFAULT PowerKit::criticalNone - -#define BACKLIGHT_MOVE_VALUE 10 -#define LOW_BATTERY 5 // % over critical -#define CRITICAL_BATTERY 10 -#define AUTO_SLEEP_BATTERY 15 -#define DEFAULT_THEME "Adwaita" -#define DEFAULT_AC_ICON "ac-adapter" -#define DEFAULT_BATTERY_ICON "battery" -#define DEFAULT_BATTERY_ICON_CRIT "battery-caution" -#define DEFAULT_BATTERY_ICON_CRIT_AC "battery-caution-charging" -#define DEFAULT_BATTERY_ICON_LOW "battery-low" -#define DEFAULT_BATTERY_ICON_LOW_AC "battery-low-charging" -#define DEFAULT_BATTERY_ICON_GOOD "battery-good" -#define DEFAULT_BATTERY_ICON_GOOD_AC "battery-good-charging" -#define DEFAULT_BATTERY_ICON_FULL "battery-full" -#define DEFAULT_BATTERY_ICON_FULL_AC "battery-full-charging" -#define DEFAULT_BATTERY_ICON_CHARGED "battery-full-charged" -#define DEFAULT_BATTERY_EMPTY "battery-empty" -#define DEFAULT_BATTERY_MISSING "battery-missing" -#define DEFAULT_VIDEO_ICON "video-display" -#define DEFAULT_SUSPEND_ICON "system-suspend" -#define DEFAULT_TRAY_ICON "preferences-other" -#define DEFAULT_NOTIFY_ICON "user-available" -#define DEFAULT_LOCK_ICON "system-lock-screen" -#define DEFAULT_HIBERNATE_ICON "system-hibernate" -#define DEFAULT_SHUTDOWN_ICON "system-shutdown" -#define DEFAULT_NONE_ICON "emblem-unreadable" -#define DEFAULT_BACKLIGHT_ICON "weather-clear" -#define DEFAULT_INFO_ICON "dialog-information" -#define DEFAULT_KEYBOARD_ICON "input-keyboard" -#define DEFAULT_MOUSE_ICON "input-mouse" -#define DEFAULT_ABOUT_ICON "dialog-question" -#define DEFAULT_SETTINGS_ICON "preferences-system" -#define DEFAULT_HELP_ICON "system-help" -#define DEFAULT_INHIBITOR_ICON "preferences-desktop-screensaver" -#define DEFAULT_APP_ICON "applications-system" - -#define DEFAULT_SUSPEND_BATTERY_ACTION PowerKit::suspendSleep -#define DEFAULT_SUSPEND_AC_ACTION PowerKit::suspendNone - +#define POWERKIT_LID_BATTERY_ACTION PowerKit::lidSleep +#define POWERKIT_LID_AC_ACTION PowerKit::lidLock +#define POWERKIT_CRITICAL_ACTION PowerKit::criticalNone +#define POWERKIT_SUSPEND_BATTERY_ACTION PowerKit::suspendSleep +#define POWERKIT_SUSPEND_AC_ACTION PowerKit::suspendNone +#define POWERKIT_BACKLIGHT_STEP 10 // +/- +#define POWERKIT_LOW_BATTERY 5 // % over critical +#define POWERKIT_CRITICAL_BATTERY 10 // % +#define POWERKIT_AUTO_SLEEP_BATTERY 15 // min +#define POWERKIT_ICON "ac-adapter" #define POWERKIT_SERVICE "org.freedesktop.PowerKit" #define POWERKIT_PATH "/PowerKit" -#define POWERKIT_FULL_PATH "/org/freedesktop/PowerKit" #define POWERKIT_MANAGER "org.freedesktop.PowerKit.Manager" #define POWERKIT_CONFIG "org.freedesktop.PowerKit.Configuration" - -#define PM_SERVICE "org.freedesktop.PowerManagement" -#define PM_PATH "/PowerManagement" -#define PM_FULL_PATH "/org/freedesktop/PowerManagement" -#define PM_TIMEOUT 60000 -#define PM_MAX_INHIBIT 18000 - -#define PM_SERVICE_INHIBIT "org.freedesktop.PowerManagement.Inhibit" -#define PM_FULL_PATH_INHIBIT "/org/freedesktop/PowerManagement/Inhibit" - -#define LOGIND_SERVICE "org.freedesktop.login1" - -#define UPOWER_SERVICE "org.freedesktop.UPower" -#define DBUS_PROPERTIES "org.freedesktop.DBus.Properties" -#define DBUS_DEVICE "Device" -#define DBUS_CHANGED "Changed" -#define DBUS_PROPERTIES_CHANGED "PropertiesChanged" - -// config keys -#define CONF_DIALOG_GEOMETRY "dialog_geometry" -#define CONF_SUSPEND_BATTERY_TIMEOUT "suspend_battery_timeout" -#define CONF_SUSPEND_BATTERY_ACTION "suspend_battery_action" -#define CONF_SUSPEND_AC_TIMEOUT "suspend_ac_timeout" -#define CONF_SUSPEND_AC_ACTION "suspend_ac_action" -#define CONF_SUSPEND_WAKEUP_HIBERNATE_BATTERY "suspend_wakeup_hibernate_battery" -#define CONF_SUSPEND_WAKEUP_HIBERNATE_AC "suspend_wakeup_hibernate_ac" -#define CONF_CRITICAL_BATTERY_TIMEOUT "critical_battery_timeout" -#define CONF_CRITICAL_BATTERY_ACTION "critical_battery_action" -#define CONF_LID_BATTERY_ACTION "lid_battery_action" -#define CONF_LID_AC_ACTION "lid_ac_action" -#define CONF_LID_DISABLE_IF_EXTERNAL "disable_lid_action_external_monitor" -#define CONF_TRAY_NOTIFY "tray_notify" -#define CONF_TRAY_SHOW "show_tray" -#define CONF_LID_XRANDR "lid_xrandr_action" -#define CONF_BACKLIGHT_BATTERY "backlight_battery_value" -#define CONF_BACKLIGHT_BATTERY_ENABLE "backlight_battery_enable" -#define CONF_BACKLIGHT_BATTERY_DISABLE_IF_LOWER "backlight_battery_disable_if_lower" -#define CONF_BACKLIGHT_AC "backlight_ac_value" -#define CONF_BACKLIGHT_AC_ENABLE "backlight_ac_enable" -#define CONF_BACKLIGHT_AC_DISABLE_IF_HIGHER "backlight_ac_disable_if_higher" -#define CONF_BACKLIGHT_MOUSE_WHEEL "backlight_mouse_wheel" -#define CONF_DIALOG "dialog_geometry" -#define CONF_WARN_ON_LOW_BATTERY "warn_on_low_battery" -#define CONF_WARN_ON_VERYLOW_BATTERY "warn_on_verylow_battery" -#define CONF_NOTIFY_ON_BATTERY "notify_on_battery" -#define CONF_NOTIFY_ON_AC "notify_on_ac" -#define CONF_NOTIFY_NEW_INHIBITOR "notify_new_inhibitor" -#define CONF_SUSPEND_LOCK_SCREEN "lock_screen_on_suspend" -#define CONF_RESUME_LOCK_SCREEN "lock_screen_on_resume" -#define CONF_ICON_THEME "icon_theme" -#define CONF_NATIVE_THEME "native_theme" -#define CONF_KERNEL_BYPASS "kernel_cmd_bypass" -#define CONF_SCREENSAVER_LOCK_CMD "screensaver_lock_cmd" -#define CONF_SCREENSAVER_TIMEOUT_BLANK "screensaver_blank_timeout" - -// screensaver - -#define PK_SCREENSAVER_LOCK_CMD "xsecurelock" -#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 +#define POWERKIT_LOGIND_SERVICE "org.freedesktop.login1" +#define POWERKIT_UPOWER_SERVICE "org.freedesktop.UPower" +#define POWERKIT_DBUS_PROPERTIES "org.freedesktop.DBus.Properties" +#define POWERKIT_SCREENSAVER_LOCK_CMD "xsecurelock" +#define POWERKIT_SCREENSAVER_TIMEOUT_BLANK 300 #endif // POWERKIT_COMMON_H diff --git a/src/powerkit_device.cpp b/src/powerkit_device.cpp index 30d8fbd..cf604be 100644 --- a/src/powerkit_device.cpp +++ b/src/powerkit_device.cpp @@ -30,6 +30,9 @@ #define PROP_DEV_VENDOR "Vendor" #define PROP_DEV_NATIVEPATH "NativePath" +#define DBUS_CHANGED "Changed" +#define DBUS_DEVICE "Device" + using namespace PowerKit; Device::Device(const QString block, QObject *parent) @@ -51,25 +54,25 @@ Device::Device(const QString block, QObject *parent) , dbusp(nullptr) { QDBusConnection system = QDBusConnection::systemBus(); - dbus = new QDBusInterface(UPOWER_SERVICE, + dbus = new QDBusInterface(POWERKIT_UPOWER_SERVICE, path, - QString("%1.%2").arg(UPOWER_SERVICE, DBUS_DEVICE), + QString("%1.%2").arg(POWERKIT_UPOWER_SERVICE, DBUS_DEVICE), system, parent); system.connect(dbus->service(), dbus->path(), - QString("%1.%2").arg(UPOWER_SERVICE, DBUS_DEVICE), + QString("%1.%2").arg(POWERKIT_UPOWER_SERVICE, DBUS_DEVICE), DBUS_CHANGED, this, SLOT(updateDeviceProperties())); - dbusp = new QDBusInterface(UPOWER_SERVICE, + dbusp = new QDBusInterface(POWERKIT_UPOWER_SERVICE, path, - DBUS_PROPERTIES, + POWERKIT_DBUS_PROPERTIES, system, parent); system.connect(dbusp->service(), dbusp->path(), - DBUS_PROPERTIES, + POWERKIT_DBUS_PROPERTIES, PROP_CHANGED, this, SLOT(updateDeviceProperties())); diff --git a/src/powerkit_dialog.cpp b/src/powerkit_dialog.cpp index 438d9ea..96392aa 100644 --- a/src/powerkit_dialog.cpp +++ b/src/powerkit_dialog.cpp @@ -113,7 +113,7 @@ void Dialog::setupWidgets() Theme::setAppTheme(); Theme::setIconTheme(); setStyleSheet("QLabel { font-weight: bold; }"); - setWindowIcon(QIcon::fromTheme(DEFAULT_AC_ICON)); + setWindowIcon(QIcon::fromTheme(POWERKIT_ICON)); // setup widgets const auto layout = new QVBoxLayout(this); @@ -461,7 +461,7 @@ void Dialog::setupWidgets() warnOnLowBattery = new QCheckBox(this); warnOnLowBattery->setText(tr("Notify on low battery")); warnOnLowBattery->setToolTip(tr("Show a notification when on low battery (%1% over critical)") - .arg(LOW_BATTERY)); + .arg(POWERKIT_LOW_BATTERY)); warnOnVeryLowBattery = new QCheckBox(this); warnOnVeryLowBattery->setText(tr("Notify on very low battery")); @@ -624,13 +624,13 @@ void Dialog::loadSettings() restoreGeometry(Settings::getValue(CONF_DIALOG_GEOMETRY).toByteArray()); } - int defaultAutoSleepBattery = AUTO_SLEEP_BATTERY; + int defaultAutoSleepBattery = POWERKIT_AUTO_SLEEP_BATTERY; if (Settings::isValid(CONF_SUSPEND_BATTERY_TIMEOUT)) { defaultAutoSleepBattery = Settings::getValue(CONF_SUSPEND_BATTERY_TIMEOUT).toInt(); } setDefaultAction(autoSleepBattery, defaultAutoSleepBattery); - int defaultAutoSleepBatteryAction = DEFAULT_SUSPEND_BATTERY_ACTION; + int defaultAutoSleepBatteryAction = POWERKIT_SUSPEND_BATTERY_ACTION; if (Settings::isValid(CONF_SUSPEND_BATTERY_ACTION)) { defaultAutoSleepBatteryAction = Settings::getValue(CONF_SUSPEND_BATTERY_ACTION).toInt(); } @@ -642,31 +642,31 @@ void Dialog::loadSettings() } setDefaultAction(autoSleepAC, defaultAutoSleepAC); - int defaultAutoSleepACAction = DEFAULT_SUSPEND_AC_ACTION; + int defaultAutoSleepACAction = POWERKIT_SUSPEND_AC_ACTION; if (Settings::isValid(CONF_SUSPEND_AC_ACTION)) { defaultAutoSleepACAction = Settings::getValue(CONF_SUSPEND_AC_ACTION).toInt(); } setDefaultAction(autoSleepACAction, defaultAutoSleepACAction); - int defaultCriticalBattery = CRITICAL_BATTERY; + int defaultCriticalBattery = POWERKIT_CRITICAL_BATTERY; if (Settings::isValid(CONF_CRITICAL_BATTERY_TIMEOUT)) { defaultCriticalBattery = Settings::getValue(CONF_CRITICAL_BATTERY_TIMEOUT).toInt(); } setDefaultAction(criticalBattery, defaultCriticalBattery); - int defaultLidActionBattery = LID_BATTERY_DEFAULT; + int defaultLidActionBattery = POWERKIT_LID_BATTERY_ACTION; if (Settings::isValid(CONF_LID_BATTERY_ACTION)) { defaultLidActionBattery = Settings::getValue(CONF_LID_BATTERY_ACTION).toInt(); } setDefaultAction(lidActionBattery, defaultLidActionBattery); - int defaultLidActionAC = LID_AC_DEFAULT; + int defaultLidActionAC = POWERKIT_LID_AC_ACTION; if (Settings::isValid(CONF_LID_AC_ACTION)) { defaultLidActionAC = Settings::getValue(CONF_LID_AC_ACTION).toInt(); } setDefaultAction(lidActionAC, defaultLidActionAC); - int defaultCriticalAction = CRITICAL_DEFAULT; + int defaultCriticalAction = POWERKIT_CRITICAL_ACTION; if (Settings::isValid(CONF_CRITICAL_BATTERY_ACTION)) { defaultCriticalAction = Settings::getValue(CONF_CRITICAL_BATTERY_ACTION).toInt(); } @@ -773,7 +773,7 @@ void Dialog::loadSettings() if (!hasCpuCoreTemp) { cpuTempLabel->setVisible(false); } screensaverBlank->setValue(Settings::getValue(CONF_SCREENSAVER_TIMEOUT_BLANK, - PK_SCREENSAVER_TIMEOUT_BLANK).toInt() / 60); + POWERKIT_SCREENSAVER_TIMEOUT_BLANK).toInt() / 60); } void Dialog::saveSettings() diff --git a/src/powerkit_manager.cpp b/src/powerkit_manager.cpp index fbb076e..6e427fd 100644 --- a/src/powerkit_manager.cpp +++ b/src/powerkit_manager.cpp @@ -42,6 +42,7 @@ #define DBUS_DEVICE_ADDED "DeviceAdded" #define DBUS_DEVICE_REMOVED "DeviceRemoved" #define DBUS_DEVICE_CHANGED "DeviceChanged" +#define DBUS_PROPERTIES_CHANGED "PropertiesChanged" #define PK_PREPARE_FOR_SUSPEND "PrepareForSuspend" #define PK_PREPARE_FOR_SLEEP "PrepareForSleep" @@ -117,7 +118,7 @@ const QDBusMessage Manager::callLogind(const QString &method) QStringList Manager::find() { QStringList result; - QDBusMessage call = QDBusMessage::createMethodCall(UPOWER_SERVICE, + QDBusMessage call = QDBusMessage::createMethodCall(POWERKIT_UPOWER_SERVICE, QString("%1/devices").arg(UPOWER_PATH), DBUS_INTROSPECTABLE, "Introspect"); @@ -151,43 +152,43 @@ void Manager::setup() return; } - system.connect(UPOWER_SERVICE, + system.connect(POWERKIT_UPOWER_SERVICE, UPOWER_PATH, - UPOWER_SERVICE, + POWERKIT_UPOWER_SERVICE, DBUS_DEVICE_ADDED, this, SLOT(deviceAdded(QDBusObjectPath))); - system.connect(UPOWER_SERVICE, + system.connect(POWERKIT_UPOWER_SERVICE, UPOWER_PATH, - UPOWER_SERVICE, + POWERKIT_UPOWER_SERVICE, DBUS_DEVICE_ADDED, this, SLOT(deviceAdded(QString))); - system.connect(UPOWER_SERVICE, + system.connect(POWERKIT_UPOWER_SERVICE, UPOWER_PATH, - UPOWER_SERVICE, + POWERKIT_UPOWER_SERVICE, DBUS_DEVICE_REMOVED, this, SLOT(deviceRemoved(QDBusObjectPath))); - system.connect(UPOWER_SERVICE, + system.connect(POWERKIT_UPOWER_SERVICE, UPOWER_PATH, - UPOWER_SERVICE, + POWERKIT_UPOWER_SERVICE, DBUS_DEVICE_REMOVED, this, SLOT(deviceRemoved(QString))); - system.connect(UPOWER_SERVICE, + system.connect(POWERKIT_UPOWER_SERVICE, UPOWER_PATH, - DBUS_PROPERTIES, + POWERKIT_DBUS_PROPERTIES, DBUS_PROPERTIES_CHANGED, this, SLOT(propertiesChanged())); - upower = new QDBusInterface(UPOWER_SERVICE, + upower = new QDBusInterface(POWERKIT_UPOWER_SERVICE, UPOWER_PATH, UPOWER_MANAGER, system, this); - logind = new QDBusInterface(LOGIND_SERVICE, + logind = new QDBusInterface(POWERKIT_LOGIND_SERVICE, LOGIND_PATH, LOGIND_MANAGER, system, @@ -573,7 +574,7 @@ void Manager::LockScreen() { qDebug() << "screen lock"; QProcess::startDetached(Settings::getValue(CONF_SCREENSAVER_LOCK_CMD, - PK_SCREENSAVER_LOCK_CMD).toString(), + POWERKIT_SCREENSAVER_LOCK_CMD).toString(), QStringList()); QProcess::execute("xset", QStringList() << "dpms" << "force" << "off"); diff --git a/src/powerkit_notify.cpp b/src/powerkit_notify.cpp index 2547eee..38f0d10 100644 --- a/src/powerkit_notify.cpp +++ b/src/powerkit_notify.cpp @@ -41,7 +41,7 @@ void SystemNotification::sendMessage(const QString& title, args << (qAppName()) // appname << static_cast(0) // id - << DEFAULT_NOTIFY_ICON // icon + << POWERKIT_ICON // icon << title // summary << text // body << QStringList() // actions diff --git a/src/powerkit_powermanagement.cpp b/src/powerkit_powermanagement.cpp index 5610aaa..3aa775d 100644 --- a/src/powerkit_powermanagement.cpp +++ b/src/powerkit_powermanagement.cpp @@ -16,6 +16,9 @@ #include "powerkit_common.h" +#define PM_TIMEOUT 60000 +#define PM_MAX_INHIBIT 18000 + using namespace PowerKit; PowerManagement::PowerManagement(QObject *parent) : QObject(parent) diff --git a/src/powerkit_screensaver.cpp b/src/powerkit_screensaver.cpp index 3828ee1..8fbeef0 100644 --- a/src/powerkit_screensaver.cpp +++ b/src/powerkit_screensaver.cpp @@ -47,7 +47,7 @@ using namespace PowerKit; ScreenSaver::ScreenSaver(QObject *parent) : QObject(parent) - , blank(PK_SCREENSAVER_TIMEOUT_BLANK) + , blank(POWERKIT_SCREENSAVER_TIMEOUT_BLANK) { timer.setInterval(PK_SCREENSAVER_TIMER); connect(&timer, SIGNAL(timeout()), @@ -99,9 +99,9 @@ void ScreenSaver::timeOut() void ScreenSaver::Update() { xlock = Settings::getValue(CONF_SCREENSAVER_LOCK_CMD, - PK_SCREENSAVER_LOCK_CMD).toString(); + POWERKIT_SCREENSAVER_LOCK_CMD).toString(); blank = Settings::getValue(CONF_SCREENSAVER_TIMEOUT_BLANK, - PK_SCREENSAVER_TIMEOUT_BLANK).toInt(); + POWERKIT_SCREENSAVER_TIMEOUT_BLANK).toInt(); int exe1 = QProcess::execute("xset", QStringList() << "-dpms"); int exe2 = QProcess::execute("xset", diff --git a/src/powerkit_settings.cpp b/src/powerkit_settings.cpp index 93abdc9..1b544ec 100644 --- a/src/powerkit_settings.cpp +++ b/src/powerkit_settings.cpp @@ -43,15 +43,15 @@ bool Settings::isValid(const QString &type) void Settings::saveDefault() { setValue(CONF_LID_BATTERY_ACTION, - LID_BATTERY_DEFAULT); + POWERKIT_LID_BATTERY_ACTION); setValue(CONF_LID_AC_ACTION, - LID_AC_DEFAULT); + POWERKIT_LID_AC_ACTION); setValue(CONF_CRITICAL_BATTERY_ACTION, - CRITICAL_DEFAULT); + POWERKIT_CRITICAL_ACTION); setValue(CONF_CRITICAL_BATTERY_TIMEOUT, - CRITICAL_BATTERY); + POWERKIT_CRITICAL_BATTERY); setValue(CONF_SUSPEND_BATTERY_TIMEOUT, - AUTO_SLEEP_BATTERY); + POWERKIT_AUTO_SLEEP_BATTERY); setValue(CONF_TRAY_NOTIFY, true); setValue(CONF_TRAY_SHOW, diff --git a/src/powerkit_settings.h b/src/powerkit_settings.h index 73d5f79..8a5028a 100644 --- a/src/powerkit_settings.h +++ b/src/powerkit_settings.h @@ -12,6 +12,42 @@ #include #include +#define CONF_DIALOG_GEOMETRY "dialog_geometry" +#define CONF_SUSPEND_BATTERY_TIMEOUT "suspend_battery_timeout" +#define CONF_SUSPEND_BATTERY_ACTION "suspend_battery_action" +#define CONF_SUSPEND_AC_TIMEOUT "suspend_ac_timeout" +#define CONF_SUSPEND_AC_ACTION "suspend_ac_action" +#define CONF_SUSPEND_WAKEUP_HIBERNATE_BATTERY "suspend_wakeup_hibernate_battery" +#define CONF_SUSPEND_WAKEUP_HIBERNATE_AC "suspend_wakeup_hibernate_ac" +#define CONF_CRITICAL_BATTERY_TIMEOUT "critical_battery_timeout" +#define CONF_CRITICAL_BATTERY_ACTION "critical_battery_action" +#define CONF_LID_BATTERY_ACTION "lid_battery_action" +#define CONF_LID_AC_ACTION "lid_ac_action" +#define CONF_LID_DISABLE_IF_EXTERNAL "disable_lid_action_external_monitor" +#define CONF_TRAY_NOTIFY "tray_notify" +#define CONF_TRAY_SHOW "show_tray" +#define CONF_LID_XRANDR "lid_xrandr_action" +#define CONF_BACKLIGHT_BATTERY "backlight_battery_value" +#define CONF_BACKLIGHT_BATTERY_ENABLE "backlight_battery_enable" +#define CONF_BACKLIGHT_BATTERY_DISABLE_IF_LOWER "backlight_battery_disable_if_lower" +#define CONF_BACKLIGHT_AC "backlight_ac_value" +#define CONF_BACKLIGHT_AC_ENABLE "backlight_ac_enable" +#define CONF_BACKLIGHT_AC_DISABLE_IF_HIGHER "backlight_ac_disable_if_higher" +#define CONF_BACKLIGHT_MOUSE_WHEEL "backlight_mouse_wheel" +#define CONF_DIALOG "dialog_geometry" +#define CONF_WARN_ON_LOW_BATTERY "warn_on_low_battery" +#define CONF_WARN_ON_VERYLOW_BATTERY "warn_on_verylow_battery" +#define CONF_NOTIFY_ON_BATTERY "notify_on_battery" +#define CONF_NOTIFY_ON_AC "notify_on_ac" +#define CONF_NOTIFY_NEW_INHIBITOR "notify_new_inhibitor" +#define CONF_SUSPEND_LOCK_SCREEN "lock_screen_on_suspend" +#define CONF_RESUME_LOCK_SCREEN "lock_screen_on_resume" +#define CONF_ICON_THEME "icon_theme" +#define CONF_NATIVE_THEME "native_theme" +#define CONF_KERNEL_BYPASS "kernel_cmd_bypass" +#define CONF_SCREENSAVER_LOCK_CMD "screensaver_lock_cmd" +#define CONF_SCREENSAVER_TIMEOUT_BLANK "screensaver_blank_timeout" + namespace PowerKit { class Settings diff --git a/src/powerkit_theme.cpp b/src/powerkit_theme.cpp index a29b2ea..e8c4d02 100644 --- a/src/powerkit_theme.cpp +++ b/src/powerkit_theme.cpp @@ -17,9 +17,10 @@ #include #include -#include "powerkit_common.h" #include "powerkit_settings.h" +#define DEFAULT_THEME "Adwaita" + using namespace PowerKit; void Theme::setAppTheme(bool darker) @@ -85,16 +86,6 @@ void Theme::setIconTheme() } qDebug() << "Using icon theme" << theme; QIcon::setThemeName(theme); -#ifdef BUNDLE_ICONS - if (theme != DEFAULT_THEME) { // validate theme - QIcon testTheme = QIcon::fromTheme(DEFAULT_AC_ICON); - if (testTheme.isNull()) { - qDebug() << "icon theme is broken, use failsafe!"; - QIcon::setThemeName(DEFAULT_THEME); - Common::saveSettings(CONF_ICON_THEME, DEFAULT_THEME); - } - } -#endif } const QPixmap Theme::drawCircleProgress(const int &progress,