Merge pull request #432 from AsmodaiP/fix-formatting-for-pipeline
Fix formatting for pipeline
This commit is contained in:
commit
fd9c62608f
|
@ -68,7 +68,7 @@ local apt_widget_button = wibox.widget({
|
||||||
apt_widget,
|
apt_widget,
|
||||||
widget = wibox.container.margin,
|
widget = wibox.container.margin,
|
||||||
},
|
},
|
||||||
widget = clickable_container,
|
widget = clickable_container, -- luacheck: ignore (todo fix)
|
||||||
})
|
})
|
||||||
|
|
||||||
--- Parses the line and creates the package table out of it
|
--- Parses the line and creates the package table out of it
|
||||||
|
|
|
@ -10,7 +10,7 @@ email_widget:set_font('Play 9')
|
||||||
email_widget:set_text("Loading...")
|
email_widget:set_text("Loading...")
|
||||||
|
|
||||||
|
|
||||||
path_to_python_in_venv = currentPath .. "/.venv/bin/python"
|
local path_to_python_in_venv = currentPath .. "/.venv/bin/python"
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
path_to_python_in_venv.." "..currentPath.."count_unread_emails.py", 20, function(_, stdout)
|
path_to_python_in_venv.." "..currentPath.."count_unread_emails.py", 20, function(_, stdout)
|
||||||
|
|
|
@ -15,235 +15,297 @@ local beautiful = require("beautiful")
|
||||||
local watch = require("awful.widget.watch")
|
local watch = require("awful.widget.watch")
|
||||||
local utils = require("awesome-wm-widgets.volume-widget.utils")
|
local utils = require("awesome-wm-widgets.volume-widget.utils")
|
||||||
|
|
||||||
|
|
||||||
local LIST_DEVICES_CMD = [[sh -c "pacmd list-sinks; pacmd list-sources"]]
|
local LIST_DEVICES_CMD = [[sh -c "pacmd list-sinks; pacmd list-sources"]]
|
||||||
local function GET_VOLUME_CMD(card, device, mixctrl, value_type) return 'amixer -c '..card..' -D '..device..' sget '..mixctrl..' '..value_type end
|
local function GET_VOLUME_CMD(card, device, mixctrl, value_type)
|
||||||
local function INC_VOLUME_CMD(card, device, mixctrl, value_type, step) return 'amixer -c '..card..' -D '..device..' sset '..mixctrl..' '..value_type..' '..step..'%+' end
|
return "amixer -c " .. card .. " -D " .. device .. " sget " .. mixctrl .. " " .. value_type
|
||||||
local function DEC_VOLUME_CMD(card, device, mixctrl, value_type, step) return 'amixer -c '..card..' -D '..device..' sset '..mixctrl..' '..value_type..' '..step..'%-' end
|
end
|
||||||
local function TOG_VOLUME_CMD(card, device, mixctrl) return 'amixer -c '..card..' -D '..device..' sset '..mixctrl..' toggle' end
|
local function INC_VOLUME_CMD(card, device, mixctrl, value_type, step)
|
||||||
|
return "amixer -c "
|
||||||
|
.. card
|
||||||
|
.. " -D "
|
||||||
|
.. device
|
||||||
|
.. " sset "
|
||||||
|
.. mixctrl
|
||||||
|
.. " "
|
||||||
|
.. value_type
|
||||||
|
.. " "
|
||||||
|
.. step
|
||||||
|
.. "%+"
|
||||||
|
end -- luacheck: ignore
|
||||||
|
local function DEC_VOLUME_CMD(card, device, mixctrl, value_type, step)
|
||||||
|
return "amixer -c "
|
||||||
|
.. card
|
||||||
|
.. " -D "
|
||||||
|
.. device
|
||||||
|
.. " sset "
|
||||||
|
.. mixctrl
|
||||||
|
.. " "
|
||||||
|
.. value_type
|
||||||
|
.. " "
|
||||||
|
.. step
|
||||||
|
.. "%-"
|
||||||
|
end -- luacheck: ignore
|
||||||
|
local function TOG_VOLUME_CMD(card, device, mixctrl)
|
||||||
|
return "amixer -c " .. card .. " -D " .. device .. " sset " .. mixctrl .. " toggle"
|
||||||
|
end -- luacheck: ignore
|
||||||
|
|
||||||
local widget_types = {
|
local widget_types = {
|
||||||
icon_and_text = require("awesome-wm-widgets.volume-widget.widgets.icon-and-text-widget"),
|
icon_and_text = require("awesome-wm-widgets.volume-widget.widgets.icon-and-text-widget"),
|
||||||
icon = require("awesome-wm-widgets.volume-widget.widgets.icon-widget"),
|
icon = require("awesome-wm-widgets.volume-widget.widgets.icon-widget"),
|
||||||
arc = require("awesome-wm-widgets.volume-widget.widgets.arc-widget"),
|
arc = require("awesome-wm-widgets.volume-widget.widgets.arc-widget"),
|
||||||
horizontal_bar = require("awesome-wm-widgets.volume-widget.widgets.horizontal-bar-widget"),
|
horizontal_bar = require("awesome-wm-widgets.volume-widget.widgets.horizontal-bar-widget"),
|
||||||
vertical_bar = require("awesome-wm-widgets.volume-widget.widgets.vertical-bar-widget")
|
vertical_bar = require("awesome-wm-widgets.volume-widget.widgets.vertical-bar-widget"),
|
||||||
}
|
}
|
||||||
local volume = {}
|
local volume = {}
|
||||||
|
|
||||||
local rows = { layout = wibox.layout.fixed.vertical }
|
local rows = { layout = wibox.layout.fixed.vertical }
|
||||||
|
|
||||||
local popup = awful.popup{
|
local popup = awful.popup({
|
||||||
bg = beautiful.bg_normal,
|
bg = beautiful.bg_normal,
|
||||||
fg = beautiful.fg_normal,
|
fg = beautiful.fg_normal,
|
||||||
ontop = true,
|
ontop = true,
|
||||||
visible = false,
|
visible = false,
|
||||||
shape = gears.shape.rounded_rect,
|
shape = gears.shape.rounded_rect,
|
||||||
border_width = 1,
|
border_width = 1,
|
||||||
border_color = beautiful.bg_focus,
|
border_color = beautiful.bg_focus,
|
||||||
maximum_width = 400,
|
maximum_width = 400,
|
||||||
offset = { y = 5 },
|
offset = { y = 5 },
|
||||||
widget = {}
|
widget = {},
|
||||||
}
|
})
|
||||||
|
|
||||||
local function build_main_line(device)
|
local function build_main_line(device)
|
||||||
if device.active_port ~= nil and device.ports[device.active_port] ~= nil then
|
if device.active_port ~= nil and device.ports[device.active_port] ~= nil then
|
||||||
return device.properties.device_description .. ' · ' .. device.ports[device.active_port]
|
return device.properties.device_description .. " · " .. device.ports[device.active_port]
|
||||||
else
|
else
|
||||||
return device.properties.device_description
|
return device.properties.device_description
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function build_rows(devices, on_checkbox_click, device_type)
|
local function build_rows(devices, on_checkbox_click, device_type)
|
||||||
local device_rows = { layout = wibox.layout.fixed.vertical }
|
local device_rows = { layout = wibox.layout.fixed.vertical }
|
||||||
for _, device in pairs(devices) do
|
for _, device in pairs(devices) do
|
||||||
|
local checkbox = wibox.widget({
|
||||||
|
checked = device.is_default,
|
||||||
|
color = beautiful.fg_normal,
|
||||||
|
paddings = 2,
|
||||||
|
shape = gears.shape.circle,
|
||||||
|
forced_width = 20,
|
||||||
|
forced_height = 20,
|
||||||
|
check_color = beautiful.fg_normal,
|
||||||
|
widget = wibox.widget.checkbox,
|
||||||
|
})
|
||||||
|
|
||||||
local checkbox = wibox.widget {
|
checkbox:connect_signal("button::press", function()
|
||||||
checked = device.is_default,
|
spawn.easy_async(
|
||||||
color = beautiful.fg_normal,
|
string.format([[sh -c 'pacmd set-default-%s "%s"']], device_type, device.name),
|
||||||
paddings = 2,
|
function()
|
||||||
shape = gears.shape.circle,
|
on_checkbox_click()
|
||||||
forced_width = 20,
|
end
|
||||||
forced_height = 20,
|
)
|
||||||
check_color = beautiful.fg_normal,
|
end)
|
||||||
widget = wibox.widget.checkbox
|
|
||||||
}
|
|
||||||
|
|
||||||
checkbox:connect_signal("button::press", function()
|
local row = wibox.widget({
|
||||||
spawn.easy_async(string.format([[sh -c 'pacmd set-default-%s "%s"']], device_type, device.name), function()
|
{
|
||||||
on_checkbox_click()
|
{
|
||||||
end)
|
{
|
||||||
end)
|
checkbox,
|
||||||
|
valign = "center",
|
||||||
|
layout = wibox.container.place,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{
|
||||||
|
text = build_main_line(device),
|
||||||
|
align = "left",
|
||||||
|
widget = wibox.widget.textbox,
|
||||||
|
},
|
||||||
|
left = 10,
|
||||||
|
layout = wibox.container.margin,
|
||||||
|
},
|
||||||
|
spacing = 8,
|
||||||
|
layout = wibox.layout.align.horizontal,
|
||||||
|
},
|
||||||
|
margins = 4,
|
||||||
|
layout = wibox.container.margin,
|
||||||
|
},
|
||||||
|
bg = beautiful.bg_normal,
|
||||||
|
fg = beautiful.fg_normal,
|
||||||
|
widget = wibox.container.background,
|
||||||
|
})
|
||||||
|
|
||||||
local row = wibox.widget {
|
row:connect_signal("mouse::enter", function(c)
|
||||||
{
|
checkbox:set_color(beautiful.fg_focus)
|
||||||
{
|
checkbox:set_check_color(beautiful.fg_focus)
|
||||||
{
|
c:set_fg(beautiful.fg_focus)
|
||||||
checkbox,
|
c:set_bg(beautiful.bg_focus)
|
||||||
valign = 'center',
|
end)
|
||||||
layout = wibox.container.place,
|
row:connect_signal("mouse::leave", function(c)
|
||||||
},
|
checkbox:set_color(beautiful.fg_normal)
|
||||||
{
|
checkbox:set_check_color(beautiful.fg_normal)
|
||||||
{
|
c:set_fg(beautiful.fg_normal)
|
||||||
text = build_main_line(device),
|
c:set_bg(beautiful.bg_normal)
|
||||||
align = 'left',
|
end)
|
||||||
widget = wibox.widget.textbox
|
|
||||||
},
|
|
||||||
left = 10,
|
|
||||||
layout = wibox.container.margin
|
|
||||||
},
|
|
||||||
spacing = 8,
|
|
||||||
layout = wibox.layout.align.horizontal
|
|
||||||
},
|
|
||||||
margins = 4,
|
|
||||||
layout = wibox.container.margin
|
|
||||||
},
|
|
||||||
bg = beautiful.bg_normal,
|
|
||||||
fg = beautiful.fg_normal,
|
|
||||||
widget = wibox.container.background
|
|
||||||
}
|
|
||||||
|
|
||||||
row:connect_signal("mouse::enter", function(c)
|
local old_cursor, old_wibox
|
||||||
checkbox:set_color(beautiful.fg_focus)
|
row:connect_signal("mouse::enter", function()
|
||||||
checkbox:set_check_color(beautiful.fg_focus)
|
local wb = mouse.current_wibox
|
||||||
c:set_fg(beautiful.fg_focus)
|
old_cursor, old_wibox = wb.cursor, wb
|
||||||
c:set_bg(beautiful.bg_focus)
|
wb.cursor = "hand1"
|
||||||
end)
|
end)
|
||||||
row:connect_signal("mouse::leave", function(c)
|
row:connect_signal("mouse::leave", function()
|
||||||
checkbox:set_color(beautiful.fg_normal)
|
if old_wibox then
|
||||||
checkbox:set_check_color(beautiful.fg_normal)
|
old_wibox.cursor = old_cursor
|
||||||
c:set_fg(beautiful.fg_normal)
|
old_wibox = nil
|
||||||
c:set_bg(beautiful.bg_normal)
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local old_cursor, old_wibox
|
row:connect_signal("button::press", function()
|
||||||
row:connect_signal("mouse::enter", function()
|
spawn.easy_async(
|
||||||
local wb = mouse.current_wibox
|
string.format([[sh -c 'pacmd set-default-%s "%s"']], device_type, device.name),
|
||||||
old_cursor, old_wibox = wb.cursor, wb
|
function()
|
||||||
wb.cursor = "hand1"
|
on_checkbox_click()
|
||||||
end)
|
end
|
||||||
row:connect_signal("mouse::leave", function()
|
)
|
||||||
if old_wibox then
|
end)
|
||||||
old_wibox.cursor = old_cursor
|
|
||||||
old_wibox = nil
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
row:connect_signal("button::press", function()
|
table.insert(device_rows, row)
|
||||||
spawn.easy_async(string.format([[sh -c 'pacmd set-default-%s "%s"']], device_type, device.name), function()
|
end
|
||||||
on_checkbox_click()
|
|
||||||
end)
|
|
||||||
end)
|
|
||||||
|
|
||||||
table.insert(device_rows, row)
|
return device_rows
|
||||||
end
|
|
||||||
|
|
||||||
return device_rows
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function build_header_row(text)
|
local function build_header_row(text)
|
||||||
return wibox.widget{
|
return wibox.widget({
|
||||||
{
|
{
|
||||||
markup = "<b>" .. text .. "</b>",
|
markup = "<b>" .. text .. "</b>",
|
||||||
align = 'center',
|
align = "center",
|
||||||
widget = wibox.widget.textbox
|
widget = wibox.widget.textbox,
|
||||||
},
|
},
|
||||||
bg = beautiful.bg_normal,
|
bg = beautiful.bg_normal,
|
||||||
fg = beautiful.fg_normal,
|
fg = beautiful.fg_normal,
|
||||||
widget = wibox.container.background
|
widget = wibox.container.background,
|
||||||
}
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
local function rebuild_popup()
|
local function rebuild_popup()
|
||||||
spawn.easy_async(LIST_DEVICES_CMD, function(stdout)
|
spawn.easy_async(LIST_DEVICES_CMD, function(stdout)
|
||||||
|
local sinks, sources = utils.extract_sinks_and_sources(stdout)
|
||||||
|
|
||||||
local sinks, sources = utils.extract_sinks_and_sources(stdout)
|
for i = 0, #rows do
|
||||||
|
rows[i] = nil
|
||||||
|
end
|
||||||
|
|
||||||
for i = 0, #rows do rows[i]=nil end
|
table.insert(rows, build_header_row("SINKS"))
|
||||||
|
table.insert(
|
||||||
|
rows,
|
||||||
|
build_rows(sinks, function()
|
||||||
|
rebuild_popup()
|
||||||
|
end, "sink")
|
||||||
|
)
|
||||||
|
table.insert(rows, build_header_row("SOURCES"))
|
||||||
|
table.insert(
|
||||||
|
rows,
|
||||||
|
build_rows(sources, function()
|
||||||
|
rebuild_popup()
|
||||||
|
end, "source")
|
||||||
|
)
|
||||||
|
|
||||||
table.insert(rows, build_header_row("SINKS"))
|
popup:setup(rows)
|
||||||
table.insert(rows, build_rows(sinks, function() rebuild_popup() end, "sink"))
|
end)
|
||||||
table.insert(rows, build_header_row("SOURCES"))
|
|
||||||
table.insert(rows, build_rows(sources, function() rebuild_popup() end, "source"))
|
|
||||||
|
|
||||||
popup:setup(rows)
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function worker(user_args)
|
local function worker(user_args)
|
||||||
|
local args = user_args or {}
|
||||||
|
|
||||||
local args = user_args or {}
|
local mixer_cmd = args.mixer_cmd or "pavucontrol"
|
||||||
|
local widget_type = args.widget_type
|
||||||
|
local refresh_rate = args.refresh_rate or 1
|
||||||
|
local step = args.step or 5
|
||||||
|
local card = args.card or 1
|
||||||
|
local device = args.device or "pulse"
|
||||||
|
local mixctrl = args.mixctrl or "Master"
|
||||||
|
local value_type = args.value_type or "-M"
|
||||||
|
local toggle_cmd = args.toggle_cmd or nil
|
||||||
|
|
||||||
local mixer_cmd = args.mixer_cmd or 'pavucontrol'
|
if widget_types[widget_type] == nil then
|
||||||
local widget_type = args.widget_type
|
volume.widget = widget_types["icon_and_text"].get_widget(args.icon_and_text_args)
|
||||||
local refresh_rate = args.refresh_rate or 1
|
else
|
||||||
local step = args.step or 5
|
volume.widget = widget_types[widget_type].get_widget(args)
|
||||||
local card = args.card or 1
|
end
|
||||||
local device = args.device or 'pulse'
|
|
||||||
local mixctrl = args.mixctrl or 'Master'
|
|
||||||
local value_type = args.value_type or '-M'
|
|
||||||
local toggle_cmd = args.toggle_cmd or nil
|
|
||||||
|
|
||||||
if widget_types[widget_type] == nil then
|
local function update_graphic(widget, stdout)
|
||||||
volume.widget = widget_types['icon_and_text'].get_widget(args.icon_and_text_args)
|
local mute = string.match(stdout, "%[(o%D%D?)%]") -- \[(o\D\D?)\] - [on] or [off]
|
||||||
else
|
if mute == "off" then
|
||||||
volume.widget = widget_types[widget_type].get_widget(args)
|
widget:mute()
|
||||||
end
|
elseif mute == "on" then
|
||||||
|
widget:unmute()
|
||||||
|
end
|
||||||
|
local volume_level = string.match(stdout, "(%d?%d?%d)%%") -- (\d?\d?\d)\%)
|
||||||
|
volume_level = string.format("% 3d", volume_level)
|
||||||
|
widget:set_volume_level(volume_level)
|
||||||
|
end
|
||||||
|
|
||||||
local function update_graphic(widget, stdout)
|
function volume:inc(s)
|
||||||
local mute = string.match(stdout, "%[(o%D%D?)%]") -- \[(o\D\D?)\] - [on] or [off]
|
spawn.easy_async(INC_VOLUME_CMD(card, device, mixctrl, value_type, s or step), function(stdout)
|
||||||
if mute == 'off' then widget:mute()
|
update_graphic(volume.widget, stdout)
|
||||||
elseif mute == 'on' then widget:unmute()
|
end)
|
||||||
end
|
end
|
||||||
local volume_level = string.match(stdout, "(%d?%d?%d)%%") -- (\d?\d?\d)\%)
|
|
||||||
volume_level = string.format("% 3d", volume_level)
|
|
||||||
widget:set_volume_level(volume_level)
|
|
||||||
end
|
|
||||||
|
|
||||||
function volume:inc(s)
|
function volume:dec(s)
|
||||||
spawn.easy_async(INC_VOLUME_CMD(card, device, mixctrl, value_type, s or step), function(stdout) update_graphic(volume.widget, stdout) end)
|
spawn.easy_async(DEC_VOLUME_CMD(card, device, mixctrl, value_type, s or step), function(stdout)
|
||||||
end
|
update_graphic(volume.widget, stdout)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
function volume:dec(s)
|
function volume:toggle()
|
||||||
spawn.easy_async(DEC_VOLUME_CMD(card, device, mixctrl, value_type, s or step), function(stdout) update_graphic(volume.widget, stdout) end)
|
if toggle_cmd == nil then
|
||||||
end
|
spawn.easy_async(TOG_VOLUME_CMD(card, device, mixctrl), function(stdout)
|
||||||
|
update_graphic(volume.widget, stdout)
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
spawn.easy_async(toggle_cmd, function(_stdout)
|
||||||
|
spawn.easy_async(GET_VOLUME_CMD(card, device, mixctrl, value_type), function(stdout)
|
||||||
|
update_graphic(volume.widget, stdout)
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function volume:toggle()
|
function volume:mixer()
|
||||||
if toggle_cmd == nil then
|
if mixer_cmd then
|
||||||
spawn.easy_async(TOG_VOLUME_CMD(card, device, mixctrl), function(stdout) update_graphic(volume.widget, stdout) end)
|
spawn.easy_async(mixer_cmd)
|
||||||
else
|
end
|
||||||
spawn.easy_async(toggle_cmd, function(_stdout) spawn.easy_async(GET_VOLUME_CMD(card, device, mixctrl, value_type), function(stdout) update_graphic(volume.widget, stdout) end) end)
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function volume:mixer()
|
volume.widget:buttons(awful.util.table.join(
|
||||||
if mixer_cmd then
|
awful.button({}, 3, function()
|
||||||
spawn.easy_async(mixer_cmd)
|
if popup.visible then
|
||||||
end
|
popup.visible = not popup.visible
|
||||||
end
|
else
|
||||||
|
rebuild_popup()
|
||||||
|
popup:move_next_to(mouse.current_widget_geometry)
|
||||||
|
end
|
||||||
|
end),
|
||||||
|
awful.button({}, 4, function()
|
||||||
|
volume:inc()
|
||||||
|
end),
|
||||||
|
awful.button({}, 5, function()
|
||||||
|
volume:dec()
|
||||||
|
end),
|
||||||
|
awful.button({}, 2, function()
|
||||||
|
volume:mixer()
|
||||||
|
end),
|
||||||
|
awful.button({}, 1, function()
|
||||||
|
volume:toggle()
|
||||||
|
end)
|
||||||
|
))
|
||||||
|
|
||||||
volume.widget:buttons(
|
watch(GET_VOLUME_CMD(card, device, mixctrl, value_type), refresh_rate, update_graphic, volume.widget)
|
||||||
awful.util.table.join(
|
|
||||||
awful.button({}, 3, function()
|
|
||||||
if popup.visible then
|
|
||||||
popup.visible = not popup.visible
|
|
||||||
else
|
|
||||||
rebuild_popup()
|
|
||||||
popup:move_next_to(mouse.current_widget_geometry)
|
|
||||||
end
|
|
||||||
end),
|
|
||||||
awful.button({}, 4, function() volume:inc() end),
|
|
||||||
awful.button({}, 5, function() volume:dec() end),
|
|
||||||
awful.button({}, 2, function() volume:mixer() end),
|
|
||||||
awful.button({}, 1, function() volume:toggle() end)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
watch(GET_VOLUME_CMD(card, device, mixctrl, value_type), refresh_rate, update_graphic, volume.widget)
|
return volume.widget
|
||||||
|
|
||||||
return volume.widget
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return setmetatable(volume, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(volume, {
|
||||||
|
__call = function(_, ...)
|
||||||
|
return worker(...)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in New Issue