configurable polling intervals and thresholds per module
This commit is contained in:
parent
0eaba947f4
commit
7a4e1859a9
11 changed files with 64 additions and 32 deletions
|
|
@ -19,8 +19,10 @@ M.BarSection {
|
||||||
readonly property var dev: UPower.displayDevice
|
readonly property var dev: UPower.displayDevice
|
||||||
readonly property real pct: (dev?.percentage ?? 0) * 100
|
readonly property real pct: (dev?.percentage ?? 0) * 100
|
||||||
readonly property bool charging: dev?.state === UPowerDeviceState.Charging
|
readonly property bool charging: dev?.state === UPowerDeviceState.Charging
|
||||||
readonly property bool _critical: pct < 15 && !charging
|
readonly property int _critThresh: M.Modules.battery.critical || 15
|
||||||
property color _stateColor: charging ? M.Theme.base0B : _critical ? M.Theme.base09 : pct < 30 ? M.Theme.base0A : M.Theme.base08
|
readonly property int _warnThresh: M.Modules.battery.warning || 25
|
||||||
|
readonly property bool _critical: pct < _critThresh && !charging
|
||||||
|
property color _stateColor: charging ? M.Theme.base0B : _critical ? M.Theme.base09 : pct < _warnThresh ? M.Theme.base0A : M.Theme.base08
|
||||||
property real _blinkOpacity: 1
|
property real _blinkOpacity: 1
|
||||||
|
|
||||||
SequentialAnimation {
|
SequentialAnimation {
|
||||||
|
|
@ -37,11 +39,11 @@ M.BarSection {
|
||||||
onChargingChanged: { _warnSent = false; _critSent = false; }
|
onChargingChanged: { _warnSent = false; _critSent = false; }
|
||||||
onPctChanged: {
|
onPctChanged: {
|
||||||
if (charging) return;
|
if (charging) return;
|
||||||
if (pct < 15 && !_critSent) {
|
if (pct < _critThresh && !_critSent) {
|
||||||
_critSent = true; _warnSent = true;
|
_critSent = true; _warnSent = true;
|
||||||
_notif.command = ["notify-send", "--urgency=critical", "--icon=battery-low", "--category=device", "Very Low Battery", "Connect to power now!"];
|
_notif.command = ["notify-send", "--urgency=critical", "--icon=battery-low", "--category=device", "Very Low Battery", "Connect to power now!"];
|
||||||
_notif.running = true;
|
_notif.running = true;
|
||||||
} else if (pct < 25 && !_warnSent) {
|
} else if (pct < _warnThresh && !_warnSent) {
|
||||||
_warnSent = true;
|
_warnSent = true;
|
||||||
_notif.command = ["notify-send", "--icon=battery-caution", "--category=device", "Low Battery"];
|
_notif.command = ["notify-send", "--icon=battery-caution", "--category=device", "Low Battery"];
|
||||||
_notif.running = true;
|
_notif.running = true;
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ M.BarSection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Timer {
|
Timer {
|
||||||
interval: 5000
|
interval: M.Modules.bluetooth.interval || 5000
|
||||||
running: true
|
running: true
|
||||||
repeat: true
|
repeat: true
|
||||||
onTriggered: proc.running = true
|
onTriggered: proc.running = true
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ M.BarSection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Timer {
|
Timer {
|
||||||
interval: 1000
|
interval: M.Modules.cpu.interval || 1000
|
||||||
running: true
|
running: true
|
||||||
repeat: true
|
repeat: true
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ M.BarSection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Timer {
|
Timer {
|
||||||
interval: 30000
|
interval: M.Modules.disk.interval || 30000
|
||||||
running: true
|
running: true
|
||||||
repeat: true
|
repeat: true
|
||||||
onTriggered: proc.running = true
|
onTriggered: proc.running = true
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ M.BarSection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Timer {
|
Timer {
|
||||||
interval: 2000
|
interval: M.Modules.memory.interval || 2000
|
||||||
running: true
|
running: true
|
||||||
repeat: true
|
repeat: true
|
||||||
onTriggered: meminfo.reload()
|
onTriggered: meminfo.reload()
|
||||||
|
|
|
||||||
|
|
@ -14,17 +14,17 @@ QtObject {
|
||||||
property var notifications: ({ enable: true })
|
property var notifications: ({ enable: true })
|
||||||
property var mpris: ({ enable: true })
|
property var mpris: ({ enable: true })
|
||||||
property var volume: ({ enable: true })
|
property var volume: ({ enable: true })
|
||||||
property var bluetooth: ({ enable: true })
|
property var bluetooth: ({ enable: true, interval: 5000 })
|
||||||
property var backlight: ({ enable: true, step: 5 })
|
property var backlight: ({ enable: true, step: 5 })
|
||||||
property var network: ({ enable: true })
|
property var network: ({ enable: true, interval: 5000 })
|
||||||
property var powerProfile: ({ enable: true })
|
property var powerProfile: ({ enable: true, interval: 5000 })
|
||||||
property var idleInhibitor: ({ enable: true })
|
property var idleInhibitor: ({ enable: true })
|
||||||
property var weather: ({ enable: true, args: ["--nerd"] })
|
property var weather: ({ enable: true, args: ["--nerd"], interval: 3600000 })
|
||||||
property var temperature: ({ enable: true })
|
property var temperature: ({ enable: true, interval: 2000, warm: 60, hot: 80 })
|
||||||
property var cpu: ({ enable: true })
|
property var cpu: ({ enable: true, interval: 1000 })
|
||||||
property var memory: ({ enable: true })
|
property var memory: ({ enable: true, interval: 2000 })
|
||||||
property var disk: ({ enable: true })
|
property var disk: ({ enable: true, interval: 30000 })
|
||||||
property var battery: ({ enable: true })
|
property var battery: ({ enable: true, warning: 25, critical: 15 })
|
||||||
property var power: ({ enable: true })
|
property var power: ({ enable: true })
|
||||||
|
|
||||||
property FileView _file: FileView {
|
property FileView _file: FileView {
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ M.BarSection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Timer {
|
Timer {
|
||||||
interval: 5000
|
interval: M.Modules.network.interval || 5000
|
||||||
running: true
|
running: true
|
||||||
repeat: true
|
repeat: true
|
||||||
onTriggered: proc.running = true
|
onTriggered: proc.running = true
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ M.BarIcon {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Timer {
|
Timer {
|
||||||
interval: 5000
|
interval: M.Modules.powerProfile.interval || 5000
|
||||||
running: true
|
running: true
|
||||||
repeat: true
|
repeat: true
|
||||||
onTriggered: proc.running = true
|
onTriggered: proc.running = true
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@ M.BarSection {
|
||||||
tooltip: "Temperature: " + root.celsius + "\u00B0C"
|
tooltip: "Temperature: " + root.celsius + "\u00B0C"
|
||||||
|
|
||||||
property int celsius: 0
|
property int celsius: 0
|
||||||
property color _stateColor: celsius > 80 ? M.Theme.base09 : celsius > 60 ? M.Theme.base0A : M.Theme.base08
|
property color _stateColor: celsius > (M.Modules.temperature.hot || 80) ? M.Theme.base09
|
||||||
|
: celsius > (M.Modules.temperature.warm || 60) ? M.Theme.base0A : M.Theme.base08
|
||||||
Behavior on _stateColor { ColorAnimation { duration: 300 } }
|
Behavior on _stateColor { ColorAnimation { duration: 300 } }
|
||||||
|
|
||||||
FileView {
|
FileView {
|
||||||
|
|
@ -17,7 +18,7 @@ M.BarSection {
|
||||||
onLoaded: root.celsius = Math.round(parseInt(text()) / 1000)
|
onLoaded: root.celsius = Math.round(parseInt(text()) / 1000)
|
||||||
}
|
}
|
||||||
Timer {
|
Timer {
|
||||||
interval: 2000
|
interval: M.Modules.temperature.interval || 2000
|
||||||
running: true
|
running: true
|
||||||
repeat: true
|
repeat: true
|
||||||
onTriggered: thermal.reload()
|
onTriggered: thermal.reload()
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ M.BarSection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Timer {
|
Timer {
|
||||||
interval: 3600000
|
interval: M.Modules.weather.interval || 3600000
|
||||||
running: true
|
running: true
|
||||||
repeat: true
|
repeat: true
|
||||||
onTriggered: proc.running = true
|
onTriggered: proc.running = true
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,13 @@ in
|
||||||
} // extra;
|
} // extra;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
intervalOpt = default: {
|
||||||
|
interval = lib.mkOption {
|
||||||
|
type = lib.types.int;
|
||||||
|
inherit default;
|
||||||
|
description = "Polling interval in milliseconds.";
|
||||||
|
};
|
||||||
|
};
|
||||||
simpleModules = lib.genAttrs [
|
simpleModules = lib.genAttrs [
|
||||||
"workspaces"
|
"workspaces"
|
||||||
"tray"
|
"tray"
|
||||||
|
|
@ -77,20 +84,18 @@ in
|
||||||
"notifications"
|
"notifications"
|
||||||
"mpris"
|
"mpris"
|
||||||
"volume"
|
"volume"
|
||||||
"bluetooth"
|
|
||||||
"network"
|
|
||||||
"powerProfile"
|
|
||||||
"idleInhibitor"
|
"idleInhibitor"
|
||||||
"temperature"
|
|
||||||
"cpu"
|
|
||||||
"memory"
|
|
||||||
"disk"
|
|
||||||
"battery"
|
|
||||||
"power"
|
"power"
|
||||||
] (name: moduleOpt name { });
|
] (name: moduleOpt name { });
|
||||||
in
|
in
|
||||||
simpleModules
|
simpleModules
|
||||||
// {
|
// {
|
||||||
|
bluetooth = moduleOpt "bluetooth" (intervalOpt 5000);
|
||||||
|
network = moduleOpt "network" (intervalOpt 5000);
|
||||||
|
powerProfile = moduleOpt "powerProfile" (intervalOpt 5000);
|
||||||
|
cpu = moduleOpt "cpu" (intervalOpt 1000);
|
||||||
|
memory = moduleOpt "memory" (intervalOpt 2000);
|
||||||
|
disk = moduleOpt "disk" (intervalOpt 30000);
|
||||||
backlight = moduleOpt "backlight" {
|
backlight = moduleOpt "backlight" {
|
||||||
step = lib.mkOption {
|
step = lib.mkOption {
|
||||||
type = lib.types.int;
|
type = lib.types.int;
|
||||||
|
|
@ -98,7 +103,31 @@ in
|
||||||
description = "Brightness adjustment step (%).";
|
description = "Brightness adjustment step (%).";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
weather = moduleOpt "weather" {
|
temperature = moduleOpt "temperature" ((intervalOpt 2000) // {
|
||||||
|
warm = lib.mkOption {
|
||||||
|
type = lib.types.int;
|
||||||
|
default = 60;
|
||||||
|
description = "Temperature threshold for warm state (°C).";
|
||||||
|
};
|
||||||
|
hot = lib.mkOption {
|
||||||
|
type = lib.types.int;
|
||||||
|
default = 80;
|
||||||
|
description = "Temperature threshold for hot state (°C).";
|
||||||
|
};
|
||||||
|
});
|
||||||
|
battery = moduleOpt "battery" {
|
||||||
|
warning = lib.mkOption {
|
||||||
|
type = lib.types.int;
|
||||||
|
default = 25;
|
||||||
|
description = "Battery percentage for warning notification.";
|
||||||
|
};
|
||||||
|
critical = lib.mkOption {
|
||||||
|
type = lib.types.int;
|
||||||
|
default = 15;
|
||||||
|
description = "Battery percentage for critical notification and blink.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
weather = moduleOpt "weather" ((intervalOpt 3600000) // {
|
||||||
args = lib.mkOption {
|
args = lib.mkOption {
|
||||||
type = lib.types.listOf lib.types.str;
|
type = lib.types.listOf lib.types.str;
|
||||||
default = [ "--nerd" ];
|
default = [ "--nerd" ];
|
||||||
|
|
@ -109,7 +138,7 @@ in
|
||||||
"Berlin"
|
"Berlin"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
theme = lib.mkOption {
|
theme = lib.mkOption {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue