Fixed scope bugs

master
Mark 2022-04-24 10:12:00 -07:00
parent bcfd464cbb
commit 58d15e1aa6
Signed by: Mark
GPG Key ID: AD62BB059C2AAEE4
8 changed files with 22 additions and 20 deletions

View File

@ -28,7 +28,7 @@ function P:set_tooltip(text)
end end
function P:new() function P:new()
widget = {} local widget = {}
setmetatable(widget, self) setmetatable(widget, self)
self.__index = self self.__index = self

View File

@ -2,7 +2,9 @@ local widget_types = {
arc = require("classes/backlight/arc_widget") arc = require("classes/backlight/arc_widget")
} }
local P = {} local P = {
name = "backlight"
}
--- ---
@ -82,13 +84,12 @@ function P:backlight_set(value)
self:_update_widget() self:_update_widget()
end end
--- ---
-- Create new -- Create new
--- ---
function P:new(args) function P:new(args)
-- Arguments -- Arguments
b = { local b = {
update_interval = args.update_interal or 5, update_interval = args.update_interal or 5,
min_value = args.min_value or 1, min_value = args.min_value or 1,
max_value = args.max_value or 100, max_value = args.max_value or 100,
@ -99,24 +100,21 @@ function P:new(args)
-- if this is false, ui will show an error and most methods will -- if this is false, ui will show an error and most methods will
-- do nothing. Updated in _get_status() -- do nothing. Updated in _get_status()
} }
setmetatable(b, self)
self.__index = self
b.widget = widget_types[b.widget_type]:new() b.widget = widget_types[b.widget_type]:new()
b.widget.widget:connect_signal("button::press", b.widget.widget:connect_signal("button::press",
function(_, _, _, button, mods) function(_, _, _, button, mods)
-- Scroll up if (button == 4) then -- Scroll up
if (button == 4) then
b:backlight_up() b:backlight_up()
-- Scroll down elseif (button == 5) then -- Scroll down
elseif (button == 5) then
b:backlight_down() b:backlight_down()
end end
end end
) )
setmetatable(b, self)
self.__index = self
-- This timer keeps mute and volume status up-to-date. -- This timer keeps mute and volume status up-to-date.
b.timer = gears.timer { b.timer = gears.timer {
timeout = b.update_interval, timeout = b.update_interval,

View File

@ -64,7 +64,7 @@ function P:set_tooltip(text)
end end
function P:new() function P:new()
widget = { local widget = {
state = "error" state = "error"
} }
setmetatable(widget, self) setmetatable(widget, self)

View File

@ -3,7 +3,9 @@ local widget_types = {
prog = require("classes/battery/prog_widget") prog = require("classes/battery/prog_widget")
} }
local P = {} local P = {
name = "battery"
}
--- ---
@ -51,7 +53,7 @@ end
function P:_check_notification() function P:_check_notification()
if not self.charging then if not self.charging then
for i=1, #self.warnings do for i=1, #self.warnings do
v = self.warnings[i] local v = self.warnings[i]
if (self.battery_percent <= v) and (not self._warning_log[i]) then if (self.battery_percent <= v) and (not self._warning_log[i]) then
self._warning_log[i] = true self._warning_log[i] = true
@ -83,7 +85,7 @@ end
--- ---
function P:new(args) function P:new(args)
-- Arguments -- Arguments
b = { local b = {
update_interval = args.update_interal or 5, update_interval = args.update_interal or 5,
widget_type = args.widget_type or "arc", widget_type = args.widget_type or "arc",
warnings = {5, 10, 25, 50}, -- Percentages to warn at (must be in order) warnings = {5, 10, 25, 50}, -- Percentages to warn at (must be in order)

View File

@ -46,7 +46,7 @@ function P:set_tooltip(text)
end end
function P:new() function P:new()
widget = { local widget = {
state = "error" state = "error"
} }
setmetatable(widget, self) setmetatable(widget, self)

View File

@ -32,7 +32,7 @@ function P:set_tooltip(text)
end end
function P:new() function P:new()
widget = {} local widget = {}
setmetatable(widget, self) setmetatable(widget, self)
self.__index = self self.__index = self

View File

@ -22,7 +22,7 @@ function P:set_tooltip(text)
end end
function P:new() function P:new()
widget = {} local widget = {}
setmetatable(widget, self) setmetatable(widget, self)
self.__index = self self.__index = self

View File

@ -3,7 +3,9 @@ local widget_types = {
arc = require("classes/volume/arc_widget") arc = require("classes/volume/arc_widget")
} }
local P = {} local P = {
name = "volume"
}
--- ---
-- Internal methods -- Internal methods
@ -166,7 +168,7 @@ end
--- ---
function P:new(args) function P:new(args)
-- Arguments -- Arguments
v = { local v = {
pa_options = args.cli_options or "", pa_options = args.cli_options or "",
pa_sink = args.pa_sink or "", pa_sink = args.pa_sink or "",
update_interval = args.update_interal or 5, update_interval = args.update_interal or 5,