fix more warnings
This commit is contained in:
parent
a0cd854a4d
commit
ed2b256407
|
@ -20,10 +20,11 @@ local dpi = require('beautiful').xresources.apply_dpi
|
||||||
-- Battery 0: Charging, 53%, 00:57:43 until charged
|
-- Battery 0: Charging, 53%, 00:57:43 until charged
|
||||||
|
|
||||||
local HOME = os.getenv("HOME")
|
local HOME = os.getenv("HOME")
|
||||||
|
local WIDGET_DIR = HOME .. '/.config/awesome/awesome-wm-widgets/battery-widget'
|
||||||
|
|
||||||
local battery_widget = {}
|
local battery_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 8'
|
local font = args.font or 'Play 8'
|
||||||
local path_to_icons = args.path_to_icons or "/usr/share/icons/Arc/status/symbolic/"
|
local path_to_icons = args.path_to_icons or "/usr/share/icons/Arc/status/symbolic/"
|
||||||
|
@ -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_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_text = args.warning_msg_text or 'Battery is dying'
|
||||||
local warning_msg_position = args.warning_msg_position or 'bottom_right'
|
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
|
local enable_battery_warning = args.enable_battery_warning
|
||||||
if enable_battery_warning == nil then
|
if enable_battery_warning == nil then
|
||||||
enable_battery_warning = true
|
enable_battery_warning = true
|
||||||
|
@ -59,7 +60,8 @@ local function worker(args)
|
||||||
widget = wibox.widget.imagebox,
|
widget = wibox.widget.imagebox,
|
||||||
resize = false
|
resize = false
|
||||||
},
|
},
|
||||||
layout = wibox.container.margin(_, 0, 0, 3)
|
bottom = 3,
|
||||||
|
layout = wibox.container.margin
|
||||||
}
|
}
|
||||||
local level_widget = wibox.widget {
|
local level_widget = wibox.widget {
|
||||||
font = font,
|
font = font,
|
||||||
|
@ -119,11 +121,11 @@ local function worker(args)
|
||||||
local batteryType = "battery-good-symbolic"
|
local batteryType = "battery-good-symbolic"
|
||||||
|
|
||||||
watch("acpi -i", timeout,
|
watch("acpi -i", timeout,
|
||||||
function(widget, stdout, stderr, exitreason, exitcode)
|
function(widget, stdout)
|
||||||
local battery_info = {}
|
local battery_info = {}
|
||||||
local capacities = {}
|
local capacities = {}
|
||||||
for s in stdout:gmatch("[^\r\n]+") do
|
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
|
if status ~= nil then
|
||||||
table.insert(battery_info, {status = status, charge = tonumber(charge_str)})
|
table.insert(battery_info, {status = status, charge = tonumber(charge_str)})
|
||||||
else
|
else
|
||||||
|
@ -133,7 +135,7 @@ local function worker(args)
|
||||||
end
|
end
|
||||||
|
|
||||||
local capacity = 0
|
local capacity = 0
|
||||||
for i, cap in ipairs(capacities) do
|
for _, cap in ipairs(capacities) do
|
||||||
capacity = capacity + cap
|
capacity = capacity + cap
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -15,12 +15,13 @@ local wibox = require("wibox")
|
||||||
local watch = require("awful.widget.watch")
|
local watch = require("awful.widget.watch")
|
||||||
|
|
||||||
local HOME = os.getenv("HOME")
|
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 font = args.font or 'Play 6'
|
||||||
local arc_thickness = args.arc_thickness or 2
|
local arc_thickness = args.arc_thickness or 2
|
||||||
|
@ -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_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_text = args.warning_msg_text or 'Battery is dying'
|
||||||
local warning_msg_position = args.warning_msg_position or 'bottom_right'
|
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
|
local enable_battery_warning = args.enable_battery_warning
|
||||||
if enable_battery_warning == nil then
|
if enable_battery_warning == nil then
|
||||||
enable_battery_warning = true
|
enable_battery_warning = true
|
||||||
|
@ -53,7 +54,7 @@ local function worker(args)
|
||||||
|
|
||||||
local text_with_background = wibox.container.background(text)
|
local text_with_background = wibox.container.background(text)
|
||||||
|
|
||||||
widget = wibox.widget {
|
batteryarc_widget = wibox.widget {
|
||||||
text_with_background,
|
text_with_background,
|
||||||
max_value = 100,
|
max_value = 100,
|
||||||
rounded_edge = true,
|
rounded_edge = true,
|
||||||
|
@ -88,7 +89,7 @@ local function worker(args)
|
||||||
local charge = 0
|
local charge = 0
|
||||||
local status
|
local status
|
||||||
for s in stdout:gmatch("[^\r\n]+") do
|
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
|
if cur_status ~= nil and charge_str ~=nil then
|
||||||
local cur_charge = tonumber(charge_str)
|
local cur_charge = tonumber(charge_str)
|
||||||
if cur_charge > charge then
|
if cur_charge > charge then
|
||||||
|
@ -132,7 +133,7 @@ local function worker(args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
watch("acpi", timeout, update_widget, widget)
|
watch("acpi", timeout, update_widget, batteryarc_widget)
|
||||||
|
|
||||||
-- Popup with battery info
|
-- Popup with battery info
|
||||||
local notification
|
local notification
|
||||||
|
@ -150,18 +151,18 @@ local function worker(args)
|
||||||
end
|
end
|
||||||
|
|
||||||
if show_notification_mode == 'on_hover' then
|
if show_notification_mode == 'on_hover' then
|
||||||
widget:connect_signal("mouse::enter", function() show_battery_status() end)
|
batteryarc_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::leave", function() naughty.destroy(notification) end)
|
||||||
elseif show_notification_mode == 'on_click' then
|
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
|
if (button == 1) then show_battery_status() end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
return widget
|
return batteryarc_widget
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return setmetatable(widget, { __call = function(_, ...)
|
return setmetatable(batteryarc_widget, { __call = function(_, ...)
|
||||||
return worker(...)
|
return worker(...)
|
||||||
end })
|
end })
|
||||||
|
|
|
@ -17,11 +17,11 @@ local GET_BRIGHTNESS_CMD = "light -G" -- "xbacklight -get"
|
||||||
local INC_BRIGHTNESS_CMD = "light -A 5" -- "xbacklight -inc 5"
|
local INC_BRIGHTNESS_CMD = "light -A 5" -- "xbacklight -inc 5"
|
||||||
local DEC_BRIGHTNESS_CMD = "light -U 5" -- "xbacklight -dec 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 get_brightness_cmd = args.get_brightness_cmd or GET_BRIGHTNESS_CMD
|
||||||
local inc_brightness_cmd = args.inc_brightness_cmd or INC_BRIGHTNESS_CMD
|
local inc_brightness_cmd = args.inc_brightness_cmd or INC_BRIGHTNESS_CMD
|
||||||
|
@ -43,7 +43,7 @@ local function worker(args)
|
||||||
widget = wibox.container.margin
|
widget = wibox.container.margin
|
||||||
}
|
}
|
||||||
|
|
||||||
widget = wibox.widget {
|
brightness_widget = wibox.widget {
|
||||||
brightness_icon,
|
brightness_icon,
|
||||||
brightness_text,
|
brightness_text,
|
||||||
layout = wibox.layout.fixed.horizontal,
|
layout = wibox.layout.fixed.horizontal,
|
||||||
|
@ -52,9 +52,9 @@ local function worker(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))
|
||||||
widget:set_text(" " .. brightness_level .. "%")
|
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
|
if (button == 4) then
|
||||||
spawn(inc_brightness_cmd, false)
|
spawn(inc_brightness_cmd, false)
|
||||||
elseif (button == 5) then
|
elseif (button == 5) then
|
||||||
|
@ -64,9 +64,9 @@ local function worker(args)
|
||||||
|
|
||||||
watch(get_brightness_cmd, timeout, update_widget, brightness_text)
|
watch(get_brightness_cmd, timeout, update_widget, brightness_text)
|
||||||
|
|
||||||
return widget
|
return brightness_widget
|
||||||
end
|
end
|
||||||
|
|
||||||
return setmetatable(widget, { __call = function(_, ...)
|
return setmetatable(brightness_widget, { __call = function(_, ...)
|
||||||
return worker(...)
|
return worker(...)
|
||||||
end })
|
end })
|
||||||
|
|
|
@ -18,11 +18,11 @@ local GET_BRIGHTNESS_CMD = "light -G" -- "xbacklight -get"
|
||||||
local INC_BRIGHTNESS_CMD = "light -A 5" -- "xbacklight -inc 5"
|
local INC_BRIGHTNESS_CMD = "light -A 5" -- "xbacklight -inc 5"
|
||||||
local DEC_BRIGHTNESS_CMD = "light -U 5" -- "xbacklight -dec 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 get_brightness_cmd = args.get_brightness_cmd or GET_BRIGHTNESS_CMD
|
||||||
local inc_brightness_cmd = args.inc_brightness_cmd or INC_BRIGHTNESS_CMD
|
local inc_brightness_cmd = args.inc_brightness_cmd or INC_BRIGHTNESS_CMD
|
||||||
|
@ -39,7 +39,7 @@ local function worker(args)
|
||||||
widget = wibox.widget.imagebox,
|
widget = wibox.widget.imagebox,
|
||||||
}
|
}
|
||||||
|
|
||||||
widget = wibox.widget {
|
brightness_widget = wibox.widget {
|
||||||
icon,
|
icon,
|
||||||
max_value = 1,
|
max_value = 1,
|
||||||
thickness = 2,
|
thickness = 2,
|
||||||
|
@ -57,9 +57,9 @@ local function worker(args)
|
||||||
brightness_level = tonumber(string.format("% 3d", brightness_level))
|
brightness_level = tonumber(string.format("% 3d", brightness_level))
|
||||||
|
|
||||||
widget.value = brightness_level / 100;
|
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
|
if (button == 4) then
|
||||||
spawn(inc_brightness_cmd, false)
|
spawn(inc_brightness_cmd, false)
|
||||||
elseif (button == 5) then
|
elseif (button == 5) then
|
||||||
|
@ -67,11 +67,11 @@ local function worker(args)
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
return setmetatable(widget, { __call = function(_, ...)
|
return setmetatable(brightness_widget, { __call = function(_, ...)
|
||||||
return worker(...)
|
return worker(...)
|
||||||
end })
|
end })
|
||||||
|
|
|
@ -16,7 +16,7 @@ local naughty = require("naughty")
|
||||||
|
|
||||||
local calendar_widget = {}
|
local calendar_widget = {}
|
||||||
|
|
||||||
local function worker(args)
|
local function worker(user_args)
|
||||||
|
|
||||||
local calendar_themes = {
|
local calendar_themes = {
|
||||||
nord = {
|
nord = {
|
||||||
|
@ -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
|
if args.theme ~= nil and calendar_themes[args.theme] == nil then
|
||||||
naughty.notify({
|
naughty.notify({
|
||||||
|
@ -154,7 +154,9 @@ local function worker(args)
|
||||||
-- Change bg color for weekends
|
-- Change bg color for weekends
|
||||||
local d = { year = date.year, month = (date.month or 1), day = (date.day or 1) }
|
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 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 {
|
local ret = wibox.widget {
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
@ -228,7 +230,8 @@ local function worker(args)
|
||||||
elseif placement == 'top_right' then
|
elseif placement == 'top_right' then
|
||||||
awful.placement.top_right(popup, { margins = { top = 30, right = 10}, parent = awful.screen.focused() })
|
awful.placement.top_right(popup, { margins = { top = 30, right = 10}, parent = awful.screen.focused() })
|
||||||
elseif placement == 'bottom_right' then
|
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
|
else
|
||||||
awful.placement.top(popup, { margins = { top = 30 }, parent = awful.screen.focused() })
|
awful.placement.top(popup, { margins = { top = 30 }, parent = awful.screen.focused() })
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,7 +20,7 @@ local CMD = [[sh -c "grep '^cpu.' /proc/stat; ps -eo '%p|%c|%C|' -o "%mem" -o '|
|
||||||
local HOME_DIR = os.getenv("HOME")
|
local HOME_DIR = os.getenv("HOME")
|
||||||
local WIDGET_DIR = HOME_DIR .. '/.config/awesome/awesome-wm-widgets/cpu-widget'
|
local WIDGET_DIR = HOME_DIR .. '/.config/awesome/awesome-wm-widgets/cpu-widget'
|
||||||
|
|
||||||
local widget = {}
|
local cpu_widget = {}
|
||||||
local cpu_rows = {
|
local cpu_rows = {
|
||||||
spacing = 4,
|
spacing = 4,
|
||||||
layout = wibox.layout.fixed.vertical,
|
layout = wibox.layout.fixed.vertical,
|
||||||
|
@ -139,11 +139,18 @@ local function worker(user_args)
|
||||||
)
|
)
|
||||||
|
|
||||||
--- By default graph widget goes from left to right, so we mirror it and push up a bit
|
--- By default graph widget goes from left to right, so we mirror it and push up a bit
|
||||||
local cpu_widget = wibox.container.margin(wibox.container.mirror(cpugraph_widget, { horizontal = true }), 0, 0, 0, 2)
|
cpu_widget = wibox.widget {
|
||||||
|
{
|
||||||
|
cpugraph_widget,
|
||||||
|
reflection = {horizontal = true},
|
||||||
|
layout = wibox.container.mirror
|
||||||
|
},
|
||||||
|
bottom = 2,
|
||||||
|
widget = wibox.container.margin
|
||||||
|
}
|
||||||
|
|
||||||
local cpus = {}
|
local cpus = {}
|
||||||
watch(CMD, timeout,
|
watch(CMD, timeout, function(widget, stdout)
|
||||||
function(widget, stdout)
|
|
||||||
local i = 1
|
local i = 1
|
||||||
local j = 1
|
local j = 1
|
||||||
for line in stdout:gmatch("[^\r\n]+") do
|
for line in stdout:gmatch("[^\r\n]+") do
|
||||||
|
@ -151,7 +158,7 @@ local function worker(user_args)
|
||||||
|
|
||||||
if cpus[i] == nil then cpus[i] = {} end
|
if cpus[i] == nil then cpus[i] = {} end
|
||||||
|
|
||||||
local name, user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice =
|
local name, user, nice, system, idle, iowait, irq, softirq, steal, _, _ =
|
||||||
line:match('(%w+)%s+(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)')
|
line:match('(%w+)%s+(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)')
|
||||||
|
|
||||||
local total = user + nice + system + idle + iowait + irq + softirq + steal
|
local total = user + nice + system + idle + iowait + irq + softirq + steal
|
||||||
|
@ -232,8 +239,8 @@ local function worker(user_args)
|
||||||
row:connect_signal("mouse::leave", function(c) c:set_bg(beautiful.bg_normal) end)
|
row:connect_signal("mouse::leave", function(c) c:set_bg(beautiful.bg_normal) end)
|
||||||
|
|
||||||
if enable_kill_button then
|
if enable_kill_button then
|
||||||
row:connect_signal("mouse::enter", function(c) kill_proccess_button.icon.opacity = 1 end)
|
row:connect_signal("mouse::enter", function() kill_proccess_button.icon.opacity = 1 end)
|
||||||
row:connect_signal("mouse::leave", function(c) kill_proccess_button.icon.opacity = 0.1 end)
|
row:connect_signal("mouse::leave", function() kill_proccess_button.icon.opacity = 0.1 end)
|
||||||
|
|
||||||
kill_proccess_button:buttons(
|
kill_proccess_button:buttons(
|
||||||
awful.util.table.join( awful.button({}, 1, function()
|
awful.util.table.join( awful.button({}, 1, function()
|
||||||
|
@ -288,6 +295,6 @@ local function worker(user_args)
|
||||||
return cpu_widget
|
return cpu_widget
|
||||||
end
|
end
|
||||||
|
|
||||||
return setmetatable(widget, { __call = function(_, ...)
|
return setmetatable(cpu_widget, { __call = function(_, ...)
|
||||||
return worker(...)
|
return worker(...)
|
||||||
end })
|
end })
|
||||||
|
|
|
@ -98,15 +98,15 @@ local function worker(user_args)
|
||||||
layout = wibox.layout.fixed.vertical,
|
layout = wibox.layout.fixed.vertical,
|
||||||
}
|
}
|
||||||
|
|
||||||
local function rebuild_widget(stdout, stderr, _, _)
|
local function rebuild_widget(containers, errors, _, _)
|
||||||
if stderr ~= '' then
|
if errors ~= '' then
|
||||||
show_warning(stderr)
|
show_warning(errors)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
for i = 0, #rows do rows[i]=nil end
|
for i = 0, #rows do rows[i]=nil end
|
||||||
|
|
||||||
for line in stdout:gmatch("[^\r\n]+") do
|
for line in containers:gmatch("[^\r\n]+") do
|
||||||
|
|
||||||
local container = parse_container(line)
|
local container = parse_container(line)
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ local function worker(user_args)
|
||||||
status_icon:emit_signal('widget::redraw_needed')
|
status_icon:emit_signal('widget::redraw_needed')
|
||||||
|
|
||||||
spawn.easy_async('docker ' .. command .. ' ' .. container['name'], function()
|
spawn.easy_async('docker ' .. command .. ' ' .. container['name'], function()
|
||||||
if stderr ~= '' then show_warning(stderr) end
|
if errors ~= '' then show_warning(errors) end
|
||||||
spawn.easy_async(string.format(LIST_CONTAINERS_CMD, number_of_containers),
|
spawn.easy_async(string.format(LIST_CONTAINERS_CMD, number_of_containers),
|
||||||
function(stdout, stderr)
|
function(stdout, stderr)
|
||||||
rebuild_widget(stdout, stderr)
|
rebuild_widget(stdout, stderr)
|
||||||
|
@ -223,10 +223,12 @@ local function worker(user_args)
|
||||||
status_icon:set_opacity(0.2)
|
status_icon:set_opacity(0.2)
|
||||||
status_icon:emit_signal('widget::redraw_needed')
|
status_icon:emit_signal('widget::redraw_needed')
|
||||||
|
|
||||||
awful.spawn.easy_async('docker ' .. command .. ' ' .. container['name'], function(stdout, stderr)
|
awful.spawn.easy_async('docker ' .. command .. ' ' .. container['name'], function(_, stderr)
|
||||||
if stderr ~= '' then show_warning(stderr) end
|
if stderr ~= '' then show_warning(stderr) end
|
||||||
spawn.easy_async(string.format(LIST_CONTAINERS_CMD, number_of_containers), function(stdout, stderr)
|
spawn.easy_async(string.format(LIST_CONTAINERS_CMD, number_of_containers),
|
||||||
rebuild_widget(stdout, stderr) end)
|
function(stdout, container_errors)
|
||||||
|
rebuild_widget(stdout, container_errors)
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
end) ) )
|
end) ) )
|
||||||
else
|
else
|
||||||
|
|
|
@ -5,15 +5,15 @@ local watch = require("awful.widget.watch")
|
||||||
|
|
||||||
local path_to_icons = "/usr/share/icons/Arc/actions/22/"
|
local path_to_icons = "/usr/share/icons/Arc/actions/22/"
|
||||||
|
|
||||||
email_widget = wibox.widget.textbox()
|
local email_widget = wibox.widget.textbox()
|
||||||
email_widget:set_font('Play 9')
|
email_widget:set_font('Play 9')
|
||||||
|
|
||||||
email_icon = wibox.widget.imagebox()
|
local email_icon = wibox.widget.imagebox()
|
||||||
email_icon:set_image(path_to_icons .. "/mail-mark-new.png")
|
email_icon:set_image(path_to_icons .. "/mail-mark-new.png")
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
"python /home/<username>/.config/awesome/email-widget/count_unread_emails.py", 20,
|
"python /home/<username>/.config/awesome/email-widget/count_unread_emails.py", 20,
|
||||||
function(widget, stdout, stderr, exitreason, exitcode)
|
function(_, stdout)
|
||||||
local unread_emails_num = tonumber(stdout) or 0
|
local unread_emails_num = tonumber(stdout) or 0
|
||||||
if (unread_emails_num > 0) then
|
if (unread_emails_num > 0) then
|
||||||
email_icon:set_image(path_to_icons .. "/mail-mark-unread.png")
|
email_icon:set_image(path_to_icons .. "/mail-mark-unread.png")
|
||||||
|
@ -26,9 +26,9 @@ watch(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
function show_emails()
|
local function show_emails()
|
||||||
awful.spawn.easy_async([[bash -c 'python /home/<username>/.config/awesome/email-widget/read_unread_emails.py']],
|
awful.spawn.easy_async([[bash -c 'python /home/<username>/.config/awesome/email-widget/read_unread_emails.py']],
|
||||||
function(stdout, stderr, reason, exit_code)
|
function(stdout)
|
||||||
naughty.notify{
|
naughty.notify{
|
||||||
text = stdout,
|
text = stdout,
|
||||||
title = "Unread Emails",
|
title = "Unread Emails",
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
-- @author Pavel Makhov
|
-- @author Pavel Makhov
|
||||||
-- @copyright 2020 Pavel Makhov
|
-- @copyright 2020 Pavel Makhov
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
|
--luacheck:ignore
|
||||||
local awful = require("awful")
|
local awful = require("awful")
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
local watch = require("awful.widget.watch")
|
local watch = require("awful.widget.watch")
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
|
|
||||||
local json = require("json")
|
|
||||||
|
|
||||||
local utils = {}
|
local utils = {}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ local function build_rows(devices, on_checkbox_click, device_type)
|
||||||
widget = wibox.widget.checkbox
|
widget = wibox.widget.checkbox
|
||||||
}
|
}
|
||||||
|
|
||||||
checkbox:connect_signal("button::press", function(c)
|
checkbox:connect_signal("button::press", function()
|
||||||
spawn.easy_async(string.format([[sh -c 'pacmd set-default-%s "%s"']], device_type, device.name), function()
|
spawn.easy_async(string.format([[sh -c 'pacmd set-default-%s "%s"']], device_type, device.name), function()
|
||||||
on_checkbox_click()
|
on_checkbox_click()
|
||||||
end)
|
end)
|
||||||
|
@ -105,19 +105,19 @@ local function build_rows(devices, on_checkbox_click, device_type)
|
||||||
row:connect_signal("mouse::leave", function(c) c:set_bg(beautiful.bg_normal) end)
|
row:connect_signal("mouse::leave", function(c) c:set_bg(beautiful.bg_normal) end)
|
||||||
|
|
||||||
local old_cursor, old_wibox
|
local old_cursor, old_wibox
|
||||||
row:connect_signal("mouse::enter", function(c)
|
row:connect_signal("mouse::enter", function()
|
||||||
local wb = mouse.current_wibox
|
local wb = mouse.current_wibox
|
||||||
old_cursor, old_wibox = wb.cursor, wb
|
old_cursor, old_wibox = wb.cursor, wb
|
||||||
wb.cursor = "hand1"
|
wb.cursor = "hand1"
|
||||||
end)
|
end)
|
||||||
row:connect_signal("mouse::leave", function(c)
|
row:connect_signal("mouse::leave", function()
|
||||||
if old_wibox then
|
if old_wibox then
|
||||||
old_wibox.cursor = old_cursor
|
old_wibox.cursor = old_cursor
|
||||||
old_wibox = nil
|
old_wibox = nil
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
row:connect_signal("button::press", function(c)
|
row:connect_signal("button::press", function()
|
||||||
spawn.easy_async(string.format([[sh -c 'pacmd set-default-%s "%s"']], device_type, device.name), function()
|
spawn.easy_async(string.format([[sh -c 'pacmd set-default-%s "%s"']], device_type, device.name), function()
|
||||||
on_checkbox_click()
|
on_checkbox_click()
|
||||||
end)
|
end)
|
||||||
|
@ -158,9 +158,9 @@ local function rebuild_popup()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function worker(args)
|
local function worker(user_args)
|
||||||
|
|
||||||
local args = args or {}
|
local args = user_args or {}
|
||||||
|
|
||||||
local widget_type = args.widget_type
|
local widget_type = args.widget_type
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ function widget.get_widget()
|
||||||
is_muted = true,
|
is_muted = true,
|
||||||
set_volume_level = function(self, new_value)
|
set_volume_level = function(self, new_value)
|
||||||
self:get_children_by_id('txt')[1]:set_text(new_value)
|
self:get_children_by_id('txt')[1]:set_text(new_value)
|
||||||
local volume_icon_name = ''
|
local volume_icon_name
|
||||||
if self.is_muted then
|
if self.is_muted then
|
||||||
volume_icon_name = 'audio-volume-muted-symbolic.svg'
|
volume_icon_name = 'audio-volume-muted-symbolic.svg'
|
||||||
else
|
else
|
||||||
|
|
|
@ -93,11 +93,12 @@ local function worker(user_args)
|
||||||
|
|
||||||
if name_dict[user_id].username == nil then
|
if name_dict[user_id].username == nil then
|
||||||
name_dict[user_id].username = ''
|
name_dict[user_id].username = ''
|
||||||
spawn.easy_async(string.format(GET_USER_CMD, host, user_id), function(stdout, stderr, reason, exit_code)
|
spawn.easy_async(string.format(GET_USER_CMD, host, user_id), function(stdout)
|
||||||
local user = json.decode(stdout)
|
local user = json.decode(stdout)
|
||||||
name_dict[tonumber(user_id)].username = user.name
|
name_dict[tonumber(user_id)].username = user.name
|
||||||
if not gfs.file_readable(PATH_TO_AVATARS .. user_id) then
|
if not gfs.file_readable(PATH_TO_AVATARS .. user_id) then
|
||||||
spawn.easy_async(string.format(DOWNLOAD_AVATAR_CMD, PATH_TO_AVATARS .. user_id, user.avatars[1].url))
|
spawn.easy_async(
|
||||||
|
string.format(DOWNLOAD_AVATAR_CMD, PATH_TO_AVATARS .. user_id, user.avatars[1].url))
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
return name_dict[user_id].username
|
return name_dict[user_id].username
|
||||||
|
@ -124,7 +125,8 @@ local function worker(user_args)
|
||||||
naughty.notify{
|
naughty.notify{
|
||||||
icon = HOME_DIR ..'/.config/awesome/awesome-wm-widgets/gerrit-widget/gerrit_icon.svg',
|
icon = HOME_DIR ..'/.config/awesome/awesome-wm-widgets/gerrit-widget/gerrit_icon.svg',
|
||||||
title = 'New Incoming Review',
|
title = 'New Incoming Review',
|
||||||
text = reviews[1].project .. '\n' .. get_name_by_user_id(reviews[1].owner._account_id) .. reviews[1].subject .. '\n',
|
text = reviews[1].project .. '\n' .. get_name_by_user_id(reviews[1].owner._account_id) ..
|
||||||
|
reviews[1].subject .. '\n',
|
||||||
run = function() spawn.with_shell("xdg-open https://" .. host .. '/' .. reviews[1]._number) end
|
run = function() spawn.with_shell("xdg-open https://" .. host .. '/' .. reviews[1]._number) end
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -174,7 +176,7 @@ local function worker(user_args)
|
||||||
widget = wibox.container.background
|
widget = wibox.container.background
|
||||||
}
|
}
|
||||||
|
|
||||||
row:connect_signal("button::release", function(_, _, _, button)
|
row:connect_signal("button::release", function()
|
||||||
spawn.with_shell("xdg-open " .. host .. '/' .. review._number)
|
spawn.with_shell("xdg-open " .. host .. '/' .. review._number)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,12 @@ local WIDGET_DIR = HOME_DIR .. '/.config/awesome/awesome-wm-widgets/github-activ
|
||||||
local ICONS_DIR = WIDGET_DIR .. '/icons/'
|
local ICONS_DIR = WIDGET_DIR .. '/icons/'
|
||||||
local CACHE_DIR = HOME_DIR .. '/.cache/awmw/github-activity-widget'
|
local CACHE_DIR = HOME_DIR .. '/.cache/awmw/github-activity-widget'
|
||||||
|
|
||||||
local GET_EVENTS_CMD = [[bash -c "cat %s/activity.json | jq '.[:%d] | [.[] | {type: .type, actor: .actor, repo: .repo, action: .payload.action, issue_url: .payload.issue.html_url, pr_url: .payload.pull_request.html_url, created_at: .created_at}]'"]]
|
local GET_EVENTS_CMD = [[sh -c "cat %s/activity.json | jq '.[:%d] | [.[] ]]
|
||||||
local DOWNLOAD_AVATAR_CMD = [[bash -c "curl -n --create-dirs -o %s/avatars/%s %s"]]
|
.. [[| {type: .type, actor: .actor, repo: .repo, action: .payload.action, issue_url: .payload.issue.html_url, ]]
|
||||||
local UPDATE_EVENTS_CMD = [[bash -c "curl -s --show-error https://api.github.com/users/%s/received_events > %s/activity.json"]]
|
.. [[pr_url: .payload.pull_request.html_url, created_at: .created_at}]'"]]
|
||||||
|
local DOWNLOAD_AVATAR_CMD = [[sh -c "curl -n --create-dirs -o %s/avatars/%s %s"]]
|
||||||
|
local UPDATE_EVENTS_CMD = [[sh -c "curl -s --show-error https://api.github.com/users/%s/received_events ]]
|
||||||
|
..[[> %s/activity.json"]]
|
||||||
|
|
||||||
--- Utility function to show warning messages
|
--- Utility function to show warning messages
|
||||||
local function show_warning(message)
|
local function show_warning(message)
|
||||||
|
@ -37,7 +40,7 @@ end
|
||||||
--- Converts string representation of date (2020-06-02T11:25:27Z) to date
|
--- Converts string representation of date (2020-06-02T11:25:27Z) to date
|
||||||
local function parse_date(date_str)
|
local function parse_date(date_str)
|
||||||
local pattern = "(%d+)%-(%d+)%-(%d+)T(%d+):(%d+):(%d+)%Z"
|
local pattern = "(%d+)%-(%d+)%-(%d+)T(%d+):(%d+):(%d+)%Z"
|
||||||
local y, m, d, h, min, sec, mil = date_str:match(pattern)
|
local y, m, d, h, min, sec, _ = date_str:match(pattern)
|
||||||
|
|
||||||
return os.time{year = y, month = m, day = d, hour = h, min = min, sec = sec}
|
return os.time{year = y, month = m, day = d, hour = h, min = min, sec = sec}
|
||||||
end
|
end
|
||||||
|
@ -129,13 +132,13 @@ local github_widget = wibox.widget {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
local function worker(args)
|
local function worker(user_args)
|
||||||
|
|
||||||
if not gfs.dir_readable(CACHE_DIR) then
|
if not gfs.dir_readable(CACHE_DIR) then
|
||||||
gfs.make_directories(CACHE_DIR)
|
gfs.make_directories(CACHE_DIR)
|
||||||
end
|
end
|
||||||
|
|
||||||
local args = args or {}
|
local args = user_args or {}
|
||||||
|
|
||||||
local icon = args.icon or ICONS_DIR .. 'github.png'
|
local icon = args.icon or ICONS_DIR .. 'github.png'
|
||||||
local username = args.username or show_warning('No username provided')
|
local username = args.username or show_warning('No username provided')
|
||||||
|
@ -147,7 +150,7 @@ local function worker(args)
|
||||||
layout = wibox.layout.fixed.vertical,
|
layout = wibox.layout.fixed.vertical,
|
||||||
}
|
}
|
||||||
|
|
||||||
local rebuild_widget = function(widget, stdout, stderr, _, _)
|
local rebuild_widget = function(stdout, stderr, _, _)
|
||||||
if stderr ~= '' then
|
if stderr ~= '' then
|
||||||
show_warning(stderr)
|
show_warning(stderr)
|
||||||
return
|
return
|
||||||
|
@ -197,7 +200,8 @@ local function worker(args)
|
||||||
|
|
||||||
local repo_info = wibox.widget {
|
local repo_info = wibox.widget {
|
||||||
{
|
{
|
||||||
markup = '<b> ' .. event.actor.display_login .. '</b> ' .. action_and_link.action_string .. ' <b>' .. event.repo.name .. '</b>',
|
markup = '<b> ' .. event.actor.display_login .. '</b> ' .. action_and_link.action_string
|
||||||
|
.. ' <b>' .. event.repo.name .. '</b>',
|
||||||
wrap = 'word',
|
wrap = 'word',
|
||||||
widget = wibox.widget.textbox
|
widget = wibox.widget.textbox
|
||||||
},
|
},
|
||||||
|
@ -261,8 +265,9 @@ local function worker(args)
|
||||||
if popup.visible then
|
if popup.visible then
|
||||||
popup.visible = not popup.visible
|
popup.visible = not popup.visible
|
||||||
else
|
else
|
||||||
spawn.easy_async(string.format(GET_EVENTS_CMD, CACHE_DIR, number_of_events), function (stdout, stderr)
|
spawn.easy_async(string.format(GET_EVENTS_CMD, CACHE_DIR, number_of_events),
|
||||||
rebuild_widget(github_widget, stdout, stderr)
|
function (stdout, stderr)
|
||||||
|
rebuild_widget(stdout, stderr)
|
||||||
popup:move_next_to(mouse.current_widget_geometry)
|
popup:move_next_to(mouse.current_widget_geometry)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
@ -276,7 +281,7 @@ local function worker(args)
|
||||||
call_now = true,
|
call_now = true,
|
||||||
autostart = true,
|
autostart = true,
|
||||||
callback = function()
|
callback = function()
|
||||||
spawn.easy_async(string.format(UPDATE_EVENTS_CMD, username, CACHE_DIR), function(stdout, stderr)
|
spawn.easy_async(string.format(UPDATE_EVENTS_CMD, username, CACHE_DIR), function(_, stderr)
|
||||||
if stderr ~= '' then show_warning(stderr) return end
|
if stderr ~= '' then show_warning(stderr) return end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue