brightness-widget: fix CI warning about shadowed variable

This commit is contained in:
Nuno Silva 2021-04-16 21:32:32 +01:00
parent e85d353933
commit 50f686d2c2
1 changed files with 9 additions and 9 deletions

View File

@ -41,7 +41,7 @@ local function worker(user_args)
local program = args.program or 'light' local program = args.program or 'light'
local step = args.step or 5 local step = args.step or 5
local base = args.base or 20 local base = args.base or 20
local level = 0 -- current brightness value local current_level = 0 -- current brightness value
local tooltip = args.tooltip or false local tooltip = args.tooltip or false
if program == 'light' then if program == 'light' then
get_brightness_cmd = 'light -G' get_brightness_cmd = 'light -G'
@ -110,12 +110,12 @@ local function worker(user_args)
local update_widget = function(widget, stdout, _, _, _) local update_widget = function(widget, stdout, _, _, _)
local brightness_level = tonumber(string.format("%.0f", stdout)) local brightness_level = tonumber(string.format("%.0f", stdout))
level = brightness_level current_level = brightness_level
widget:set_value(brightness_level) widget:set_value(brightness_level)
end end
function brightness_widget:set(value) function brightness_widget:set(value)
level = value current_level = value
spawn.easy_async(set_brightness_cmd .. value, function() spawn.easy_async(set_brightness_cmd .. value, function()
spawn.easy_async(get_brightness_cmd, function(out) spawn.easy_async(get_brightness_cmd, function(out)
update_widget(brightness_widget.widget, out) update_widget(brightness_widget.widget, out)
@ -128,15 +128,15 @@ local function worker(user_args)
-- avoid toggling between '0' and 'almost 0' -- avoid toggling between '0' and 'almost 0'
old_level = 1 old_level = 1
end end
if level < 0.1 then if current_level < 0.1 then
-- restore previous level -- restore previous level
level = old_level current_level = old_level
else else
-- save current brightness for later -- save current brightness for later
old_level = level old_level = current_level
level = 0 current_level = 0
end end
brightness_widget:set(level) brightness_widget:set(current_level)
end end
function brightness_widget:inc() function brightness_widget:inc()
spawn.easy_async(inc_brightness_cmd, function() spawn.easy_async(inc_brightness_cmd, function()
@ -168,7 +168,7 @@ local function worker(user_args)
awful.tooltip { awful.tooltip {
objects = { brightness_widget.widget }, objects = { brightness_widget.widget },
timer_function = function() timer_function = function()
return level .. " %" return current_level .. " %"
end, end,
} }
end end