Fix luacheck warnings
This commit is contained in:
parent
4741325f8b
commit
97d127b774
|
@ -8,7 +8,7 @@ local DIR = os.getenv("HOME") .. "/.config/awesome/pacman-widget/"
|
||||||
local ICON_DIR = DIR .. "icons/"
|
local ICON_DIR = DIR .. "icons/"
|
||||||
|
|
||||||
local pacman_widget = {}
|
local pacman_widget = {}
|
||||||
local config = {}
|
local config, timer = {}, {}
|
||||||
|
|
||||||
config.interval = 600
|
config.interval = 600
|
||||||
config.popup_bg_color = "#222222"
|
config.popup_bg_color = "#222222"
|
||||||
|
@ -38,13 +38,13 @@ local function worker(user_args)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id = "txt",
|
id = "txt",
|
||||||
font = font,
|
font = args.font,
|
||||||
widget = wibox.widget.textbox
|
widget = wibox.widget.textbox
|
||||||
},
|
},
|
||||||
spacing = 5,
|
spacing = 5,
|
||||||
layout = wibox.layout.fixed.horizontal,
|
layout = wibox.layout.fixed.horizontal,
|
||||||
}
|
}
|
||||||
function pacman_widget:set(new_value)
|
function pacman_widget.set(new_value)
|
||||||
pacman_widget:get_children_by_id("txt")[1]:set_text(new_value)
|
pacman_widget:get_children_by_id("txt")[1]:set_text(new_value)
|
||||||
pacman_widget:get_children_by_id("icon")[1]:set_image(
|
pacman_widget:get_children_by_id("icon")[1]:set_image(
|
||||||
ICON_DIR .. (tonumber(new_value) > 0 and "pacman" or "pacman-full") .. ".svg"
|
ICON_DIR .. (tonumber(new_value) > 0 and "pacman" or "pacman-full") .. ".svg"
|
||||||
|
@ -83,7 +83,7 @@ local function worker(user_args)
|
||||||
popup.visible = false
|
popup.visible = false
|
||||||
else
|
else
|
||||||
popup.visible = true
|
popup.visible = true
|
||||||
popup:move_next_to(mouse.current_widget_geometry)
|
popup:move_next_to(_G.mouse.current_widget_geometry)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
)
|
)
|
||||||
|
@ -106,7 +106,7 @@ local function worker(user_args)
|
||||||
if not busy then
|
if not busy then
|
||||||
c:set_opacity(1)
|
c:set_opacity(1)
|
||||||
c:emit_signal("widget::redraw_needed")
|
c:emit_signal("widget::redraw_needed")
|
||||||
local wb = mouse.current_wibox
|
local wb = _G.mouse.current_wibox
|
||||||
old_cursor, old_wibox = wb.cursor, wb
|
old_cursor, old_wibox = wb.cursor, wb
|
||||||
wb.cursor = "hand2"
|
wb.cursor = "hand2"
|
||||||
end
|
end
|
||||||
|
@ -129,7 +129,8 @@ local function worker(user_args)
|
||||||
old_wibox = nil
|
old_wibox = nil
|
||||||
end
|
end
|
||||||
if not busy then
|
if not busy then
|
||||||
busy, one_shot = true, true
|
busy = true
|
||||||
|
local one_shot = true
|
||||||
awful.spawn.with_line_callback("bash -c " .. DIR .. "upgrade", {
|
awful.spawn.with_line_callback("bash -c " .. DIR .. "upgrade", {
|
||||||
stdout = function()
|
stdout = function()
|
||||||
if one_shot then
|
if one_shot then
|
||||||
|
@ -139,19 +140,20 @@ local function worker(user_args)
|
||||||
end,
|
end,
|
||||||
stderr = function(line)
|
stderr = function(line)
|
||||||
if (line ~= nil and line ~= "") then
|
if (line ~= nil and line ~= "") then
|
||||||
notification = string.find(line, "warning") and
|
if string.find(line, "warning") then
|
||||||
naughty.notify({
|
naughty.notify({
|
||||||
title = "Warning!",
|
title = "Warning!",
|
||||||
text = line,
|
text = line,
|
||||||
timeout = 0
|
timeout = 0
|
||||||
})
|
})
|
||||||
or
|
else
|
||||||
naughty.notify({
|
naughty.notify({
|
||||||
preset = naughty.config.presets.critical,
|
preset = naughty.config.presets.critical,
|
||||||
title = "Error!",
|
title = "Error!",
|
||||||
text = line,
|
text = line,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
exit = function()
|
exit = function()
|
||||||
upgrading, busy = false, false
|
upgrading, busy = false, false
|
||||||
|
@ -163,14 +165,14 @@ local function worker(user_args)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
_, timer = awful.widget.watch([[bash -c "checkupdates 2>/dev/null"]],
|
timer = select(2, awful.widget.watch([[bash -c "checkupdates 2>/dev/null"]],
|
||||||
_config.interval,
|
_config.interval,
|
||||||
function(widget, stdout)
|
function(widget, stdout)
|
||||||
local upgrades_tbl = {}
|
local upgrades_tbl = {}
|
||||||
for value in stdout:gmatch("([^\n]+)") do
|
for value in stdout:gmatch("([^\n]+)") do
|
||||||
upgrades_tbl[#upgrades_tbl+1] = value
|
upgrades_tbl[#upgrades_tbl+1] = value
|
||||||
end
|
end
|
||||||
widget:set(#upgrades_tbl)
|
widget.set(#upgrades_tbl)
|
||||||
|
|
||||||
local popup_header_height, popup_row_height = 30, 20
|
local popup_header_height, popup_row_height = 30, 20
|
||||||
local header = wibox.widget {
|
local header = wibox.widget {
|
||||||
|
@ -197,7 +199,7 @@ local function worker(user_args)
|
||||||
|
|
||||||
for k, v in ipairs(upgrades_tbl) do
|
for k, v in ipairs(upgrades_tbl) do
|
||||||
for i = 1, #rows.children do
|
for i = 1, #rows.children do
|
||||||
if v == rows.children[i]:get_txt() then goto continue end
|
if v == rows.children[i].get_txt() then goto continue end
|
||||||
end
|
end
|
||||||
local row = wibox.widget{
|
local row = wibox.widget{
|
||||||
{
|
{
|
||||||
|
@ -214,8 +216,8 @@ local function worker(user_args)
|
||||||
},
|
},
|
||||||
layout = wibox.layout.ratio.horizontal,
|
layout = wibox.layout.ratio.horizontal,
|
||||||
}
|
}
|
||||||
function row:get_txt() return row:get_children_by_id("txt")[1].text end
|
function row.get_txt() return row:get_children_by_id("txt")[1].text end
|
||||||
function row:set_idx(idx) row:get_children_by_id("idx")[1]:set_text(idx) end
|
function row.set_idx(idx) row:get_children_by_id("idx")[1]:set_text(idx) end
|
||||||
row:ajust_ratio(2, 0.1, 0.9, 0)
|
row:ajust_ratio(2, 0.1, 0.9, 0)
|
||||||
rows:insert(k, row)
|
rows:insert(k, row)
|
||||||
::continue::
|
::continue::
|
||||||
|
@ -246,7 +248,7 @@ local function worker(user_args)
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
pacman_widget
|
pacman_widget
|
||||||
)
|
))
|
||||||
return pacman_widget
|
return pacman_widget
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue