Warn only if battery is discharging

This commit is contained in:
Stefano Mazzucco 2018-07-12 21:18:32 +01:00
parent 6844a9d3c0
commit 6e447e88f0
2 changed files with 37 additions and 5 deletions

View File

@ -55,11 +55,16 @@ function widget:update()
self.tooltip:set_text(
percentage .. "%" .. " - " .. self.device.state.name)
if (
percentage <= self.critical_percentage
or warning_level == WarningLevel.Low
or warning_level == WarningLevel.Critical
) then
local should_warn = (
self.device.state == power.enums.BatteryState.Discharging and
(
percentage <= self.critical_percentage
or warning_level == WarningLevel.Low
or warning_level == WarningLevel.Critical
)
)
if should_warn then
local msg = (warning_level.name == "None" and "Low" or warning_level.name) .. " battery!"
naughty.notify({
preset = naughty.config.presets.critical,

View File

@ -0,0 +1,27 @@
package = "power_widget"
version = "0.3.5-1"
source = {
url = "git://github.com/stefano-m/awesome-power_widget",
tag = "v0.3.5"
}
description = {
summary = "A Power widget for the Awesome Window Manager",
detailed = [[
Monitor your power devices in Awesome with UPower and DBus.
]],
homepage = "https://github.com/stefano-m/awesome-power_widget",
license = "GPL v3"
}
supported_platforms = {
"linux"
}
dependencies = {
"lua >= 5.1",
"upower_dbus >= 0.3.0, < 0.4"
}
build = {
type = "builtin",
modules = {
power_widget = "power_widget.lua"
}
}