init luarocks
This commit is contained in:
parent
f147f9b4c8
commit
603204c064
|
@ -15,6 +15,7 @@
|
|||
"luacheckrc",
|
||||
"luadoc",
|
||||
"luarocks",
|
||||
"lunarmodules",
|
||||
"mktemp",
|
||||
"mousegrabber",
|
||||
"rockspec",
|
||||
|
|
|
@ -46,6 +46,6 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: leafo/gh-actions-lua@v9
|
||||
- uses: leafo/gh-actions-luarocks@v4
|
||||
- run: luarocks lint awesome-slot-dev-1.rockspec
|
||||
- uses: luarocks/gh-actions-lua@v10
|
||||
- uses: luarocks/gh-actions-luarocks@v5
|
||||
- run: luarocks lint awesome-battery_widget-dev-1.rockspec
|
||||
|
|
|
@ -10,7 +10,7 @@ jobs:
|
|||
needs: affected
|
||||
if: >-
|
||||
${{
|
||||
github.repository == 'Aire-One/awesome-slot' &&
|
||||
github.repository == 'Aire-One/awesome-battery_widget' &&
|
||||
( github.ref_name == 'master' || startsWith(github.ref, 'refs/tags/') ) &&
|
||||
needs.affected.outputs.rockspecs
|
||||
}}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package = "awesome-battery_widget"
|
||||
version = "dev-1"
|
||||
|
||||
source = {
|
||||
url = "git+https://github.com/Aire-One/awesome-battery_widget.git",
|
||||
}
|
||||
|
||||
description = {
|
||||
summary = "A UPowerGlib based battery widget for the Awesome WM with a basic widget template mechanism! 🔋",
|
||||
homepage = "https://github.com/Aire-One/awesome-battery_widget",
|
||||
license = "*** please specify a license ***",
|
||||
}
|
||||
|
||||
build = {
|
||||
type = "builtin",
|
||||
modules = {
|
||||
["awesome-battery_widget.init"] = "src/awesome-battery_widget/init.lua",
|
||||
},
|
||||
copy_directories = {
|
||||
"doc",
|
||||
},
|
||||
}
|
|
@ -1,22 +1,21 @@
|
|||
---------------------------------------------------------------------------
|
||||
-- A battery widget based on the UPower deamon.
|
||||
-- A battery widget based on the UPower daemon.
|
||||
--
|
||||
-- @author Aire-One
|
||||
-- @copyright 2020 Aire-One
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
local upower = require('lgi').require('UPowerGlib')
|
||||
local upower = require("lgi").require "UPowerGlib"
|
||||
|
||||
local gtable = require 'gears.table'
|
||||
local gtimer = require 'gears.timer'
|
||||
local wbase = require 'wibox.widget.base'
|
||||
local gtable = require "gears.table"
|
||||
local gtimer = require "gears.timer" -- cspell: ignore gtimer
|
||||
local wbase = require "wibox.widget.base" -- cspell: ignore wbase
|
||||
|
||||
local setmetatable = setmetatable -- luacheck: ignore setmetatable
|
||||
|
||||
local battery_widget = {}
|
||||
local mt = {}
|
||||
|
||||
|
||||
--- Helper to get the path of all connected power devices.
|
||||
-- @treturn table The list of all power devices path.
|
||||
-- @staticfct battery_widget.list_devices
|
||||
|
@ -51,7 +50,7 @@ end
|
|||
-- @treturn string The BAT0 device path.
|
||||
-- @staticfct battery_widget.get_BAT0_device_path
|
||||
function battery_widget.get_BAT0_device_path()
|
||||
local bat0_path = '/org/freedesktop/UPower/devices/battery_BAT0'
|
||||
local bat0_path = "/org/freedesktop/UPower/devices/battery_BAT0"
|
||||
return bat0_path
|
||||
end
|
||||
|
||||
|
@ -65,15 +64,14 @@ end
|
|||
-- @staticfct battery_widget.to_clock
|
||||
function battery_widget.to_clock(seconds)
|
||||
if seconds <= 0 then
|
||||
return '00:00';
|
||||
return "00:00"
|
||||
else
|
||||
local hours = string.format('%02.f', math.floor(seconds/3600));
|
||||
local mins = string.format('%02.f', math.floor(seconds/60 - hours*60));
|
||||
return hours .. ':' .. mins
|
||||
local hours = string.format("%02.f", math.floor(seconds / 3600))
|
||||
local mins = string.format("%02.f", math.floor(seconds / 60 - hours * 60))
|
||||
return hours .. ":" .. mins
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--- Gives the default widget to use if user didn't specify one.
|
||||
-- The default widget used is an `empty_widget` instance.
|
||||
-- @treturn widget The default widget to use.
|
||||
|
@ -81,17 +79,15 @@ local function default_template ()
|
|||
return wbase.empty_widget()
|
||||
end
|
||||
|
||||
|
||||
--- The device monitored by the widget.
|
||||
-- @property device
|
||||
-- @tparam UPowerGlib.Device device
|
||||
|
||||
--- Emited when the UPower device notify an update.
|
||||
--- Emitted when the UPower device notify an update.
|
||||
-- @signal upower::update
|
||||
-- @tparam battery_widget widget The widget.
|
||||
-- @tparam UPowerGlib.Device device The Upower device.
|
||||
|
||||
|
||||
--- battery_widget constructor.
|
||||
--
|
||||
-- This function creates a new `battery_widget` instance. This widget watches
|
||||
|
@ -109,31 +105,29 @@ end
|
|||
function battery_widget.new(args)
|
||||
args = gtable.crush({
|
||||
widget_template = default_template(),
|
||||
device_path = '',
|
||||
use_display_device = false
|
||||
device_path = "",
|
||||
use_display_device = false,
|
||||
}, args or {})
|
||||
|
||||
local widget = wbase.make_widget_from_value(args.widget_template)
|
||||
|
||||
widget.device = args.use_display_device
|
||||
and upower.Client():get_display_device()
|
||||
widget.device = args.use_display_device and upower.Client():get_display_device()
|
||||
or battery_widget.get_device(args.device_path)
|
||||
|
||||
-- Attach signals:
|
||||
widget.device.on_notify = function(d)
|
||||
widget:emit_signal('upower::update', d)
|
||||
widget:emit_signal("upower::update", d)
|
||||
end
|
||||
|
||||
-- Call an update cycle if the user asked to instan update the widget.
|
||||
-- Call an update cycle if the user asked to instant update the widget.
|
||||
if args.instant_update then
|
||||
gtimer.delayed_call(widget.emit_signal, widget, 'upower::update', widget.device)
|
||||
gtimer.delayed_call(widget.emit_signal, widget, "upower::update", widget.device)
|
||||
end
|
||||
|
||||
return widget
|
||||
end
|
||||
|
||||
|
||||
function mt.__call(self, ...)
|
||||
function mt.__call(_, ...)
|
||||
return battery_widget.new(...)
|
||||
end
|
||||
|
Loading…
Reference in New Issue