mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-25 07:57:19 +00:00
fix update pkg
add notify flag
This commit is contained in:
parent
3bd73d0458
commit
e5006ed2d6
@ -20,7 +20,7 @@ optdepends=("amarok: for music player monitor"
|
||||
makedepends=('automoc4' 'cmake')
|
||||
source=(https://github.com/arcan1s/awesome-widgets/releases/download/V.${pkgver}/${_pkgname}-${pkgver}-src.tar.xz)
|
||||
install=${pkgname}.install
|
||||
md5sums=('b9e77735ca866164395b2b9d4124e0ac')
|
||||
md5sums=('acfaaec09f7b8544e8e844b26f763388')
|
||||
backup=('usr/share/config/plasma-dataengine-extsysmon.conf')
|
||||
|
||||
prepare() {
|
||||
|
@ -20,7 +20,7 @@ optdepends=("amarok: for music player monitor"
|
||||
makedepends=('cmake' 'extra-cmake-modules')
|
||||
source=(https://github.com/arcan1s/awesome-widgets/releases/download/V.${pkgver}/${_pkgname}-${pkgver}-src.tar.xz)
|
||||
install=${pkgname}.install
|
||||
md5sums=('b9e77735ca866164395b2b9d4124e0ac')
|
||||
md5sums=('acfaaec09f7b8544e8e844b26f763388')
|
||||
backup=('etc/xdg/plasma-dataengine-extsysmon.conf')
|
||||
|
||||
prepare() {
|
||||
|
@ -14,6 +14,9 @@
|
||||
|
||||
<group name="Advanced">
|
||||
<!-- advanced -->
|
||||
<entry name="notify" type="bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="background" type="bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
|
@ -58,6 +58,7 @@ Item {
|
||||
"batInTooltipColor": plasmoid.configuration.batInTooltipColor
|
||||
}
|
||||
|
||||
property alias cfg_notify: notify.checked
|
||||
property alias cfg_background: background.checked
|
||||
property alias cfg_customTime: customTime.text
|
||||
property alias cfg_customUptime: customUptime.text
|
||||
@ -69,6 +70,20 @@ Item {
|
||||
Column {
|
||||
id: pageColumn
|
||||
width: units.gridUnit * 25
|
||||
Row {
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
QtControls.Label {
|
||||
height: parent.heigth
|
||||
width: parent.width * 2 / 5
|
||||
}
|
||||
QtControls.CheckBox {
|
||||
id: notify
|
||||
width: parent.width * 3 / 5
|
||||
text: i18n("Enable notifications")
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
|
@ -179,7 +179,7 @@ Item {
|
||||
if (debug) console.log("[main::onUserConfiguringChanged]")
|
||||
|
||||
// init submodule
|
||||
AWKeys.initKeys(plasmoid.configuration.text, tooltipSettings)
|
||||
AWKeys.initKeys(plasmoid.configuration.text, tooltipSettings, plasmoid.configuration.notify)
|
||||
}
|
||||
|
||||
function action_checkUpdates() {
|
||||
|
@ -84,7 +84,8 @@ AWKeys::~AWKeys()
|
||||
|
||||
|
||||
void AWKeys::initKeys(const QString pattern,
|
||||
const QMap<QString, QVariant> tooltipParams)
|
||||
const QMap<QString, QVariant> tooltipParams,
|
||||
const bool popup)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -107,6 +108,7 @@ void AWKeys::initKeys(const QString pattern,
|
||||
toolTip = new AWToolTip(this, tooltipParams);
|
||||
|
||||
ready = true;
|
||||
enablePopup = popup;
|
||||
}
|
||||
|
||||
|
||||
@ -438,7 +440,8 @@ bool AWKeys::setDataBySource(const QString sourceName,
|
||||
for (int i=0; i<data.keys().count(); i++) {
|
||||
if (data.keys()[i] == QString("ac")) {
|
||||
// notification
|
||||
if ((values[QString("ac")] == params[QString("acOnline")].toString()) != data[QString("ac")].toBool()) {
|
||||
if ((enablePopup) &&
|
||||
((values[QString("ac")] == params[QString("acOnline")].toString()) != data[QString("ac")].toBool())) {
|
||||
if (data[QString("ac")].toBool())
|
||||
AWActions::sendNotification(QString("event"), i18n("AC online"));
|
||||
else
|
||||
@ -458,7 +461,8 @@ bool AWKeys::setDataBySource(const QString sourceName,
|
||||
} else if (sourceName == QString("cpu/system/TotalLoad")) {
|
||||
// cpu
|
||||
// notification
|
||||
if ((data[QString("value")].toFloat() >= 90.0) && (values[QString("cpu")].toFloat() < 90.0))
|
||||
if ((enablePopup) &&
|
||||
((data[QString("value")].toFloat() >= 90.0) && (values[QString("cpu")].toFloat() < 90.0)))
|
||||
AWActions::sendNotification(QString("event"), i18n("High CPU load"));
|
||||
// value
|
||||
values[QString("cpu")] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1);
|
||||
@ -517,7 +521,8 @@ bool AWKeys::setDataBySource(const QString sourceName,
|
||||
mount.remove(QString("partitions")).remove(QString("/filllevel"));
|
||||
for (int i=0; i<mountDevices.count(); i++)
|
||||
if (mountDevices[i] == mount) {
|
||||
if ((data[QString("value")].toFloat() >= 90.0) && (values[QString("hdd") + QString::number(i)].toFloat() < 90.0))
|
||||
if ((enablePopup) &&
|
||||
((data[QString("value")].toFloat() >= 90.0) && (values[QString("hdd") + QString::number(i)].toFloat() < 90.0)))
|
||||
AWActions::sendNotification(QString("event"), i18n("Free space on %1 less than 10%", mount));
|
||||
values[QString("hdd") + QString::number(i)] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1);
|
||||
break;
|
||||
@ -583,7 +588,7 @@ bool AWKeys::setDataBySource(const QString sourceName,
|
||||
// percentage
|
||||
float value = 100.0 * values[QString("memmb")].toFloat() / values[QString("memtotmb")].toFloat();
|
||||
// notification
|
||||
if ((value >= 90.0) && (values[QString("mem")].toFloat() < 90.0))
|
||||
if ((enablePopup) && ((value >= 90.0) && (values[QString("mem")].toFloat() < 90.0)))
|
||||
AWActions::sendNotification(QString("event"), i18n("High memory usage"));
|
||||
// value
|
||||
values[QString("mem")] = QString("%1").arg(value, 5, 'f', 1);
|
||||
@ -591,7 +596,7 @@ bool AWKeys::setDataBySource(const QString sourceName,
|
||||
} else if (sourceName == QString("netdev")) {
|
||||
// network device
|
||||
// notification
|
||||
if (values[QString("netdev")] != data[QString("value")].toString())
|
||||
if ((enablePopup) && (values[QString("netdev")] != data[QString("value")].toString()))
|
||||
AWActions::sendNotification(QString("event"), i18n("Network device has been changed to %1",
|
||||
data[QString("value")].toString()));
|
||||
// value
|
||||
@ -656,7 +661,7 @@ bool AWKeys::setDataBySource(const QString sourceName,
|
||||
// percentage
|
||||
float value = 100.0 * values[QString("swapmb")].toFloat() / values[QString("swaptotmb")].toFloat();
|
||||
// notification
|
||||
if ((value > 0.0) && (values[QString("swap")].toFloat() == 0.0))
|
||||
if ((enablePopup) && ((value > 0.0) && (values[QString("swap")].toFloat() == 0.0)))
|
||||
AWActions::sendNotification(QString("event"), i18n("Swap is used"));
|
||||
// value
|
||||
values[QString("swap")] = QString("%1").arg(value, 5, 'f', 1);
|
||||
|
@ -50,7 +50,8 @@ public:
|
||||
~AWKeys();
|
||||
|
||||
Q_INVOKABLE void initKeys(const QString pattern,
|
||||
const QMap<QString, QVariant> tooltipParams);
|
||||
const QMap<QString, QVariant> tooltipParams,
|
||||
const bool popup = false);
|
||||
Q_INVOKABLE bool isDebugEnabled();
|
||||
Q_INVOKABLE QString parsePattern(const QString pattern);
|
||||
Q_INVOKABLE QString toolTipImage();
|
||||
@ -106,6 +107,7 @@ private:
|
||||
RequestedItem requestedItem = Nothing;
|
||||
// variables
|
||||
bool debug = false;
|
||||
bool enablePopup = false;
|
||||
bool ready = false;
|
||||
QList<GraphicalItem *> graphicalItems;
|
||||
QList<ExtScript *> extScripts;
|
||||
|
@ -694,7 +694,7 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source)
|
||||
} else if (source == QString("netdev")) {
|
||||
setData(source, QString("value"), getNetworkDevice());
|
||||
} else if (source == QString("pkg")) {
|
||||
if (pkgTimeUpdate > MSEC_IN_HOUR) {
|
||||
if (pkgTimeUpdate > SEC_IN_HOUR) {
|
||||
for (int i=0; i<externalUpgrade.count(); i++)
|
||||
setData(source, QString("pkgcount") + QString::number(i), externalUpgrade[i]->run());
|
||||
pkgTimeUpdate = 0;
|
||||
|
@ -18,9 +18,9 @@
|
||||
#ifndef EXTSYSMON_H
|
||||
#define EXTSYSMON_H
|
||||
|
||||
#ifndef MSEC_IN_HOUR
|
||||
#define MSEC_IN_HOUR 60*60*1000
|
||||
#endif /* MSEC_IN_HOUR */
|
||||
#ifndef SEC_IN_HOUR
|
||||
#define SEC_IN_HOUR 60*60
|
||||
#endif /* SEC_IN_HOUR */
|
||||
|
||||
#include <Plasma/DataEngine>
|
||||
#include <QProcess>
|
||||
@ -64,7 +64,7 @@ private:
|
||||
QList<int> times;
|
||||
bool debug;
|
||||
// FIXME dirty hack to avoid update package information every second
|
||||
int pkgTimeUpdate = MSEC_IN_HOUR;
|
||||
int pkgTimeUpdate = SEC_IN_HOUR;
|
||||
// reread configuration
|
||||
QStringList allHddDevices;
|
||||
QString getAllHdd();
|
||||
|
Loading…
Reference in New Issue
Block a user