diff --git a/packages/PKGBUILD b/packages/PKGBUILD index 263a080..746c035 100644 --- a/packages/PKGBUILD +++ b/packages/PKGBUILD @@ -9,8 +9,7 @@ arch=('i686' 'x86_64') url="https://arcanis.me/projects/awesome-widgets" license=('GPL3') depends=('ksysguard' 'plasma-framework') -optdepends=("catalyst: for GPU monitor" - "hddtemp: for HDD temperature monitor" +optdepends=("hddtemp: for HDD temperature monitor" "smartmontools: for HDD temperature monitor" "mpd: for music player monitor" "nvidia-utils: for GPU monitor") @@ -20,22 +19,14 @@ install=${pkgname}.install md5sums=('5953ba518191bb6fff83cdb8633c735c') backup=('etc/xdg/plasma-dataengine-extsysmon.conf') -prepare() { - rm -rf "${srcdir}/build" - mkdir "${srcdir}/build" -} - build () { - cd "${srcdir}/build" - cmake -DKDE_INSTALL_USE_QT_SYS_PATHS=ON \ - -DCMAKE_BUILD_TYPE=Optimization \ - -DCMAKE_INSTALL_PREFIX=/usr \ - -DBUILD_FUTURE=ON \ - "../${_pkgname}" - make + cmake -B build -S "${_pkgname}" \ + -DCMAKE_BUILD_TYPE=Optimization \ + -DBUILD_FUTURE=ON \ + -DBUILD_TESTING=OFF + cmake --build build } package() { - cd "${srcdir}/build" - make DESTDIR="${pkgdir}" install + DESTDIR="$pkgdir" cmake --install build } diff --git a/sources/awesome-widget/plugin/awdataenginemapper.cpp b/sources/awesome-widget/plugin/awdataenginemapper.cpp index cab3e4a..0509df6 100644 --- a/sources/awesome-widget/plugin/awdataenginemapper.cpp +++ b/sources/awesome-widget/plugin/awdataenginemapper.cpp @@ -358,7 +358,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy m_formatter[key] = _units == KSysGuard::UnitCelsius ? AWKeysAggregator::FormatterType::Temperature : AWKeysAggregator::FormatterType::Integer; } - } else if (_source == "Local") { + } else if (_source == "extsysmon/time/now") { // time m_map.insert(_source, "time"); m_formatter["time"] = AWKeysAggregator::FormatterType::Time; @@ -410,7 +410,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy m_formatter[key] = AWKeysAggregator::FormatterType::Temperature; } - QStringList foundKeys = keysFromSource(_source); + auto foundKeys = keysFromSource(_source); // rewrite formatters for custom ones QStringList customFormattersKeys; @@ -425,7 +425,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy // drop key from dictionary if no one user requested key required it qCInfo(LOG_AW) << "Looking for keys" << foundKeys << "in" << _keys; - bool required = _keys.isEmpty() || std::any_of(foundKeys.cbegin(), foundKeys.cend(), [&_keys](const QString &key) { + auto required = _keys.isEmpty() || std::any_of(foundKeys.cbegin(), foundKeys.cend(), [&_keys](const QString &key) { return _keys.contains(key); }); if (!required) { diff --git a/sources/awesome-widget/plugin/awkeys.cpp b/sources/awesome-widget/plugin/awkeys.cpp index b336cc3..d3bfbfa 100644 --- a/sources/awesome-widget/plugin/awkeys.cpp +++ b/sources/awesome-widget/plugin/awkeys.cpp @@ -373,7 +373,6 @@ void AWKeys::setDataBySource(const QString &_source, const KSysGuard::SensorInfo } m_mutex.lock(); - // HACK workaround for time values which are stored in the different path std::for_each(tags.cbegin(), tags.cend(), [this, &_data](const QString &tag) { m_values[tag] = _data.payload; }); m_mutex.unlock(); } diff --git a/sources/awesome-widget/plugin/awkeysaggregator.cpp b/sources/awesome-widget/plugin/awkeysaggregator.cpp index 71607c5..44dc0a4 100644 --- a/sources/awesome-widget/plugin/awkeysaggregator.cpp +++ b/sources/awesome-widget/plugin/awkeysaggregator.cpp @@ -113,26 +113,26 @@ QString AWKeysAggregator::formatter(const QVariant &_data, const QString &_key, output = QString("%1").arg(temperature(_data.toDouble()), 5, 'f', 1); break; case FormatterType::Time: - output = _data.toDateTime().toString(); + output = QDateTime::fromSecsSinceEpoch(_data.toLongLong()).toString(); break; case FormatterType::TimeCustom: output = m_customTime; [&output, loc, this](const QDateTime &dt) { for (auto &key : m_timeKeys) output.replace(QString("$%1").arg(key), loc.toString(dt, key)); - }(_data.toDateTime()); + }(QDateTime::fromSecsSinceEpoch(_data.toLongLong())); break; case FormatterType::TimeISO: - output = _data.toDateTime().toString(Qt::ISODate); + output = QDateTime::fromSecsSinceEpoch(_data.toLongLong()).toString(Qt::ISODate); break; case FormatterType::TimeLong: - output = loc.toString(_data.toDateTime(), QLocale::LongFormat); + output = loc.toString(QDateTime::fromSecsSinceEpoch(_data.toLongLong()), QLocale::LongFormat); break; case FormatterType::TimeShort: - output = loc.toString(_data.toDateTime(), QLocale::ShortFormat); + output = loc.toString(QDateTime::fromSecsSinceEpoch(_data.toLongLong()), QLocale::ShortFormat); break; case FormatterType::Timestamp: - output = QString("%1").arg(_data.toDateTime().toMSecsSinceEpoch() / 1000.0, 10, 'f', 0); + output = _data.toString(); break; case FormatterType::Uptime: case FormatterType::UptimeCustom: diff --git a/sources/awesomewidgets/owmweatherprovider.cpp b/sources/awesomewidgets/owmweatherprovider.cpp index 70d9126..85f9710 100644 --- a/sources/awesomewidgets/owmweatherprovider.cpp +++ b/sources/awesomewidgets/owmweatherprovider.cpp @@ -93,9 +93,9 @@ QVariantHash OWMWeatherProvider::parseSingleJson(const QVariantMap &_json) const // main data QVariantMap mainWeather = _json["main"].toMap(); if (!weather.isEmpty()) { - output[tag("humidity")] = mainWeather["humidity"].toFloat(); - output[tag("pressure")] = mainWeather["pressure"].toFloat(); - output[tag("temperature")] = mainWeather["temp"].toFloat(); + output[tag("humidity")] = mainWeather["humidity"].toDouble(); + output[tag("pressure")] = mainWeather["pressure"].toDouble(); + output[tag("temperature")] = mainWeather["temp"].toDouble(); } // timestamp diff --git a/sources/awesomewidgets/yahooweatherprovider.cpp b/sources/awesomewidgets/yahooweatherprovider.cpp index 7fd52fe..561e9d8 100644 --- a/sources/awesomewidgets/yahooweatherprovider.cpp +++ b/sources/awesomewidgets/yahooweatherprovider.cpp @@ -86,7 +86,7 @@ QVariantHash YahooWeatherProvider::parseCurrent(const QVariantMap &_json, const values[tag("timestamp")] = condition["date"].toString(); values[tag("humidity")] = _atmosphere["humidity"].toInt(); // HACK temporary fix of invalid values on Yahoo! side - values[tag("pressure")] = static_cast(_atmosphere["pressure"].toFloat() / 33.863753); + values[tag("pressure")] = static_cast(_atmosphere["pressure"].toDouble() / 33.863753); return values; } @@ -103,7 +103,7 @@ QVariantHash YahooWeatherProvider::parseForecast(const QVariantMap &_json) const values[tag("weatherId")] = id; values[tag("timestamp")] = weatherMap["date"].toString(); // yahoo provides high and low temperatures. Lets calculate average one - values[tag("temperature")] = (weatherMap["high"].toFloat() + weatherMap["low"].toFloat()) / 2.0; + values[tag("temperature")] = (weatherMap["high"].toDouble() + weatherMap["low"].toDouble()) / 2.0; // ... and no forecast data for humidity and pressure values[tag("humidity")] = 0; values[tag("pressure")] = 0.0; diff --git a/sources/extsysmon/extsysmonaggregator.cpp b/sources/extsysmon/extsysmonaggregator.cpp index d166c13..2849bdb 100644 --- a/sources/extsysmon/extsysmonaggregator.cpp +++ b/sources/extsysmon/extsysmonaggregator.cpp @@ -32,6 +32,7 @@ #include "quotessource.h" #include "requestsource.h" #include "systeminfosource.h" +#include "timesource.h" #include "upgradesource.h" #include "weathersource.h" @@ -86,6 +87,8 @@ void ExtSysMonAggregator::init(const QHash &_config) createSensor("quotes", i18n("Quotes"), new QuotesSource(this, {})); // system createSensor("system", i18n("System"), new SystemInfoSource(this, {})); + // current time + createSensor("time", i18n("Time"), new TimeSource(this, {})); // upgrade createSensor("upgrade", i18n("Upgrades"), new UpgradeSource(this, {})); // weather diff --git a/sources/extsysmon/extsysmonaggregator.h b/sources/extsysmon/extsysmonaggregator.h index 0c0fefc..c43216c 100644 --- a/sources/extsysmon/extsysmonaggregator.h +++ b/sources/extsysmon/extsysmonaggregator.h @@ -15,8 +15,7 @@ * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * ***************************************************************************/ -#ifndef EXTSYSMONAGGREGATOR_H -#define EXTSYSMONAGGREGATOR_H +#pragma once #include #include @@ -39,6 +38,3 @@ private: void createSensor(const QString &_id, const QString &_name, AbstractExtSysMonSource *_source); void init(const QHash &_config); }; - - -#endif /* EXTSYSMONAGGREGATOR_H */ diff --git a/sources/extsysmonsources/timesource.cpp b/sources/extsysmonsources/timesource.cpp new file mode 100644 index 0000000..9e02dea --- /dev/null +++ b/sources/extsysmonsources/timesource.cpp @@ -0,0 +1,62 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets 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 General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#include "timesource.h" + +#include +#include + +#include "awdebug.h" + + +TimeSource::TimeSource(QObject *_parent, const QStringList &_args) + : AbstractExtSysMonSource(_parent, _args) +{ + Q_ASSERT(_args.count() == 0); + qCDebug(LOG_ESS) << __PRETTY_FUNCTION__; +} + + +QVariant TimeSource::data(const QString &_source) +{ + qCDebug(LOG_ESS) << "Source" << _source; + + if (_source == "now") { + return QDateTime::currentSecsSinceEpoch(); + } + + return {}; +} + + +KSysGuard::SensorInfo *TimeSource::initialData(const QString &_source) const +{ + qCDebug(LOG_ESS) << "Source" << _source; + + auto data = new KSysGuard::SensorInfo(); + data->name = "Current time"; + data->variantType = QVariant::LongLong; + data->unit = KSysGuard::UnitSecond; + + return data; +} + + +QStringList TimeSource::sources() const +{ + return QStringList({"now"}); +} diff --git a/sources/extsysmonsources/timesource.h b/sources/extsysmonsources/timesource.h new file mode 100644 index 0000000..bb780d8 --- /dev/null +++ b/sources/extsysmonsources/timesource.h @@ -0,0 +1,36 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets 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 General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#pragma once + +#include + +#include "abstractextsysmonsource.h" +#include "extitemaggregator.h" + + +class TimeSource : public AbstractExtSysMonSource +{ + Q_OBJECT + +public: + explicit TimeSource(QObject *_parent, const QStringList &_args); + QVariant data(const QString &_source) override; + [[nodiscard]] KSysGuard::SensorInfo *initialData(const QString &_source) const override; + void run() override{}; + [[nodiscard]] QStringList sources() const override; +};