Skip to content

Commit

Permalink
fix more warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
streetturtle committed Dec 6, 2020
1 parent a0cd854 commit ed2b256
Show file tree
Hide file tree
Showing 14 changed files with 242 additions and 221 deletions.
20 changes: 11 additions & 9 deletions battery-widget/battery.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ local dpi = require('beautiful').xresources.apply_dpi
-- Battery 0: Charging, 53%, 00:57:43 until charged

local HOME = os.getenv("HOME")
local WIDGET_DIR = HOME .. '/.config/awesome/awesome-wm-widgets/battery-widget'

local battery_widget = {}
local function worker(args)
local args = args or {}
local function worker(user_args)
local args = user_args or {}

local font = args.font or 'Play 8'
local path_to_icons = args.path_to_icons or "/usr/share/icons/Arc/status/symbolic/"
Expand All @@ -39,7 +40,7 @@ local function worker(args)
local warning_msg_title = args.warning_msg_title or 'Huston, we have a problem'
local warning_msg_text = args.warning_msg_text or 'Battery is dying'
local warning_msg_position = args.warning_msg_position or 'bottom_right'
local warning_msg_icon = args.warning_msg_icon or HOME .. '/.config/awesome/awesome-wm-widgets/batteryarc-widget/spaceman.jpg'
local warning_msg_icon = args.warning_msg_icon or WIDGET_DIR .. '/spaceman.jpg'
local enable_battery_warning = args.enable_battery_warning
if enable_battery_warning == nil then
enable_battery_warning = true
Expand All @@ -59,7 +60,8 @@ local function worker(args)
widget = wibox.widget.imagebox,
resize = false
},
layout = wibox.container.margin(_, 0, 0, 3)
bottom = 3,
layout = wibox.container.margin
}
local level_widget = wibox.widget {
font = font,
Expand Down Expand Up @@ -119,11 +121,11 @@ local function worker(args)
local batteryType = "battery-good-symbolic"

watch("acpi -i", timeout,
function(widget, stdout, stderr, exitreason, exitcode)
function(widget, stdout)
local battery_info = {}
local capacities = {}
for s in stdout:gmatch("[^\r\n]+") do
local status, charge_str, time = string.match(s, '.+: (%a+), (%d?%d?%d)%%,?(.*)')
local status, charge_str, _ = string.match(s, '.+: (%a+), (%d?%d?%d)%%,?(.*)')
if status ~= nil then
table.insert(battery_info, {status = status, charge = tonumber(charge_str)})
else
Expand All @@ -133,7 +135,7 @@ local function worker(args)
end

local capacity = 0
for i, cap in ipairs(capacities) do
for _, cap in ipairs(capacities) do
capacity = capacity + cap
end

Expand Down Expand Up @@ -184,12 +186,12 @@ local function worker(args)
battery_widget:connect_signal("mouse::enter", function() show_battery_status(batteryType) end)
battery_widget:connect_signal("mouse::leave", function() naughty.destroy(notification) end)
elseif display_notification_onClick then
battery_widget:connect_signal("button::press", function(_,_,_,button)
battery_widget:connect_signal("button::press", function(_,_,_,button)
if (button == 3) then show_battery_status(batteryType) end
end)
battery_widget:connect_signal("mouse::leave", function() naughty.destroy(notification) end)
end

return wibox.container.margin(battery_widget, margin_left, margin_right)
end

Expand Down
25 changes: 13 additions & 12 deletions batteryarc-widget/batteryarc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ local wibox = require("wibox")
local watch = require("awful.widget.watch")

local HOME = os.getenv("HOME")
local WIDGET_DIR = HOME .. '/.config/awesome/awesome-wm-widgets/batteryarc-widget'

local widget = {}
local batteryarc_widget = {}

local function worker(args)
local function worker(user_args)

local args = args or {}
local args = user_args or {}

local font = args.font or 'Play 6'
local arc_thickness = args.arc_thickness or 2
Expand All @@ -38,7 +39,7 @@ local function worker(args)
local warning_msg_title = args.warning_msg_title or 'Houston, we have a problem'
local warning_msg_text = args.warning_msg_text or 'Battery is dying'
local warning_msg_position = args.warning_msg_position or 'bottom_right'
local warning_msg_icon = args.warning_msg_icon or HOME .. '/.config/awesome/awesome-wm-widgets/batteryarc-widget/spaceman.jpg'
local warning_msg_icon = args.warning_msg_icon or WIDGET_DIR .. '/spaceman.jpg'
local enable_battery_warning = args.enable_battery_warning
if enable_battery_warning == nil then
enable_battery_warning = true
Expand All @@ -53,7 +54,7 @@ local function worker(args)

local text_with_background = wibox.container.background(text)

widget = wibox.widget {
batteryarc_widget = wibox.widget {
text_with_background,
max_value = 100,
rounded_edge = true,
Expand Down Expand Up @@ -88,7 +89,7 @@ local function worker(args)
local charge = 0
local status
for s in stdout:gmatch("[^\r\n]+") do
local cur_status, charge_str, time = string.match(s, '.+: (%a+), (%d?%d?%d)%%,?(.*)')
local cur_status, charge_str, _ = string.match(s, '.+: (%a+), (%d?%d?%d)%%,?(.*)')
if cur_status ~= nil and charge_str ~=nil then
local cur_charge = tonumber(charge_str)
if cur_charge > charge then
Expand Down Expand Up @@ -132,7 +133,7 @@ local function worker(args)
end
end

watch("acpi", timeout, update_widget, widget)
watch("acpi", timeout, update_widget, batteryarc_widget)

-- Popup with battery info
local notification
Expand All @@ -150,18 +151,18 @@ local function worker(args)
end

if show_notification_mode == 'on_hover' then
widget:connect_signal("mouse::enter", function() show_battery_status() end)
widget:connect_signal("mouse::leave", function() naughty.destroy(notification) end)
batteryarc_widget:connect_signal("mouse::enter", function() show_battery_status() end)
batteryarc_widget:connect_signal("mouse::leave", function() naughty.destroy(notification) end)
elseif show_notification_mode == 'on_click' then
widget:connect_signal('button::press', function(_, _, _, button)
batteryarc_widget:connect_signal('button::press', function(_, _, _, button)
if (button == 1) then show_battery_status() end
end)
end

return widget
return batteryarc_widget

end

return setmetatable(widget, { __call = function(_, ...)
return setmetatable(batteryarc_widget, { __call = function(_, ...)
return worker(...)
end })
16 changes: 8 additions & 8 deletions brightness-widget/brightness.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ local GET_BRIGHTNESS_CMD = "light -G" -- "xbacklight -get"
local INC_BRIGHTNESS_CMD = "light -A 5" -- "xbacklight -inc 5"
local DEC_BRIGHTNESS_CMD = "light -U 5" -- "xbacklight -dec 5"

local widget = {}
local brightness_widget = {}

local function worker(args)
local function worker(user_args)

local args = args or {}
local args = user_args or {}

local get_brightness_cmd = args.get_brightness_cmd or GET_BRIGHTNESS_CMD
local inc_brightness_cmd = args.inc_brightness_cmd or INC_BRIGHTNESS_CMD
Expand All @@ -43,7 +43,7 @@ local function worker(args)
widget = wibox.container.margin
}

widget = wibox.widget {
brightness_widget = wibox.widget {
brightness_icon,
brightness_text,
layout = wibox.layout.fixed.horizontal,
Expand All @@ -52,9 +52,9 @@ local function worker(args)
local update_widget = function(widget, stdout, _, _, _)
local brightness_level = tonumber(string.format("%.0f", stdout))
widget:set_text(" " .. brightness_level .. "%")
end,
end

widget:connect_signal("button::press", function(_, _, _, button)
brightness_widget:connect_signal("button::press", function(_, _, _, button)
if (button == 4) then
spawn(inc_brightness_cmd, false)
elseif (button == 5) then
Expand All @@ -64,9 +64,9 @@ local function worker(args)

watch(get_brightness_cmd, timeout, update_widget, brightness_text)

return widget
return brightness_widget
end

return setmetatable(widget, { __call = function(_, ...)
return setmetatable(brightness_widget, { __call = function(_, ...)
return worker(...)
end })
18 changes: 9 additions & 9 deletions brightnessarc-widget/brightnessarc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ local GET_BRIGHTNESS_CMD = "light -G" -- "xbacklight -get"
local INC_BRIGHTNESS_CMD = "light -A 5" -- "xbacklight -inc 5"
local DEC_BRIGHTNESS_CMD = "light -U 5" -- "xbacklight -dec 5"

local widget = {}
local brightness_widget = {}

local function worker(args)
local function worker(user_args)

local args = args or {}
local args = user_args or {}

local get_brightness_cmd = args.get_brightness_cmd or GET_BRIGHTNESS_CMD
local inc_brightness_cmd = args.inc_brightness_cmd or INC_BRIGHTNESS_CMD
Expand All @@ -39,7 +39,7 @@ local function worker(args)
widget = wibox.widget.imagebox,
}

widget = wibox.widget {
brightness_widget = wibox.widget {
icon,
max_value = 1,
thickness = 2,
Expand All @@ -57,21 +57,21 @@ local function worker(args)
brightness_level = tonumber(string.format("% 3d", brightness_level))

widget.value = brightness_level / 100;
end,
end

widget:connect_signal("button::press", function(_, _, _, button)
brightness_widget:connect_signal("button::press", function(_, _, _, button)
if (button == 4) then
spawn(inc_brightness_cmd, false)
elseif (button == 5) then
spawn(dec_brightness_cmd, false)
end
end)

watch(get_brightness_cmd, timeout, update_widget, widget)
watch(get_brightness_cmd, timeout, update_widget, brightness_widget)

return widget
return brightness_widget
end

return setmetatable(widget, { __call = function(_, ...)
return setmetatable(brightness_widget, { __call = function(_, ...)
return worker(...)
end })
11 changes: 7 additions & 4 deletions calendar-widget/calendar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ local naughty = require("naughty")

local calendar_widget = {}

local function worker(args)
local function worker(user_args)

local calendar_themes = {
nord = {
Expand Down Expand Up @@ -82,7 +82,7 @@ local function worker(args)

}

local args = args or {}
local args = user_args or {}

if args.theme ~= nil and calendar_themes[args.theme] == nil then
naughty.notify({
Expand Down Expand Up @@ -154,7 +154,9 @@ local function worker(args)
-- Change bg color for weekends
local d = { year = date.year, month = (date.month or 1), day = (date.day or 1) }
local weekday = tonumber(os.date('%w', os.time(d)))
local default_bg = (weekday == 0 or weekday == 6) and calendar_themes[theme].weekend_day_bg or calendar_themes[theme].bg
local default_bg = (weekday == 0 or weekday == 6)
and calendar_themes[theme].weekend_day_bg
or calendar_themes[theme].bg
local ret = wibox.widget {
{
{
Expand Down Expand Up @@ -228,7 +230,8 @@ local function worker(args)
elseif placement == 'top_right' then
awful.placement.top_right(popup, { margins = { top = 30, right = 10}, parent = awful.screen.focused() })
elseif placement == 'bottom_right' then
awful.placement.bottom_right(popup, { margins = { bottom = 30, right = 10}, parent = awful.screen.focused() })
awful.placement.bottom_right(popup, { margins = { bottom = 30, right = 10},
parent = awful.screen.focused() })
else
awful.placement.top(popup, { margins = { top = 30 }, parent = awful.screen.focused() })
end
Expand Down
Loading

0 comments on commit ed2b256

Please sign in to comment.