diff --git a/power_widget.lua b/power_widget.lua index af16998..0a7fd6a 100644 --- a/power_widget.lua +++ b/power_widget.lua @@ -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, diff --git a/rockspec/power_widget-0.3.5-1.rockspec b/rockspec/power_widget-0.3.5-1.rockspec new file mode 100644 index 0000000..252f665 --- /dev/null +++ b/rockspec/power_widget-0.3.5-1.rockspec @@ -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" + } +}