Update to use upower_dbus 0.3.0

This commit is contained in:
Stefano Mazzucco 2017-11-05 15:18:12 +00:00
parent bebe9fd845
commit 8ed443ed88
6 changed files with 35 additions and 4 deletions

View File

@ -22,6 +22,8 @@ local awful = require("awful")
local naughty = require("naughty") local naughty = require("naughty")
local power = require("upower_dbus") local power = require("upower_dbus")
local WarningLevel = power.enums.BatteryWarningLevel
local DeviceType = power.enums.DeviceType
-- Awesome DBus C API -- Awesome DBus C API
local cdbus = dbus -- luacheck: ignore local cdbus = dbus -- luacheck: ignore
@ -52,12 +54,12 @@ function widget:update()
local warning_level = self.device.warninglevel local warning_level = self.device.warninglevel
self.tooltip:set_text( self.tooltip:set_text(
percentage .. "%" .. " - " .. self.device.state) percentage .. "%" .. " - " .. self.device.state.name)
if warning_level == "Low" or warning_level == "Critical" then if warning_level == WarningLevel.Low or warning_level == WarningLevel.Critical then
naughty.notify({ naughty.notify({
preset = naughty.config.presets.critical, preset = naughty.config.presets.critical,
title = warning_level .. " battery!", title = warning_level.name .. " battery!",
text = percentage .. "% remaining"}) text = percentage .. "% remaining"})
end end
else else
@ -121,7 +123,9 @@ function widget:init()
for _, d in ipairs(self.manager.devices) do for _, d in ipairs(self.manager.devices) do
devices[d.type] = d devices[d.type] = d
end end
self.device = get_data(devices["Battery"] or devices["Line Power"]) self.device = get_data(
devices[DeviceType.Battery]
or devices[DeviceType"Line Power"])
self.tooltip = awful.tooltip({ objects = { widget },}) self.tooltip = awful.tooltip({ objects = { widget },})
self.gui_client = "" self.gui_client = ""

View File

@ -0,0 +1,27 @@
package = "power_widget"
version = "0.3.0-1"
source = {
url = "git://github.com/stefano-m/awesome-power_widget",
tag = "v0.3.0"
}
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"
}
}