Merge branch 'master' into hide-logout-on-mouse-leave
This commit is contained in:
commit
4b048254e4
|
@ -1 +1 @@
|
|||
@streetturtle
|
||||
* @streetturtle
|
||||
|
|
|
@ -15,335 +15,356 @@ local naughty = require("naughty")
|
|||
local gears = require("gears")
|
||||
local beautiful = require("beautiful")
|
||||
|
||||
--- Utility Function to handle alternative paths
|
||||
local function script_path()
|
||||
local str = debug.getinfo(2, "S").source:sub(2)
|
||||
return str:match("(.*/)")
|
||||
end
|
||||
|
||||
local HOME_DIR = os.getenv("HOME")
|
||||
local WIDGET_DIR = HOME_DIR .. '/.config/awesome/awesome-wm-widgets/apt-widget'
|
||||
local ICONS_DIR = WIDGET_DIR .. '/icons/'
|
||||
local WIDGET_DIR = script_path()
|
||||
local ICONS_DIR = WIDGET_DIR .. "/icons/"
|
||||
|
||||
local LIST_PACKAGES = [[sh -c "LC_ALL=c apt list --upgradable 2>/dev/null"]]
|
||||
|
||||
--- Utility function to show warning messages
|
||||
local function show_warning(message)
|
||||
naughty.notify{
|
||||
preset = naughty.config.presets.critical,
|
||||
title = 'Docker Widget',
|
||||
text = message}
|
||||
naughty.notify({
|
||||
preset = naughty.config.presets.critical,
|
||||
title = "Docker Widget",
|
||||
text = message,
|
||||
})
|
||||
end
|
||||
|
||||
local wibox_popup = wibox {
|
||||
ontop = true,
|
||||
visible = false,
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 4)
|
||||
end,
|
||||
border_width = 1,
|
||||
border_color = beautiful.bg_focus,
|
||||
max_widget_size = 500,
|
||||
height = 500,
|
||||
width = 300,
|
||||
}
|
||||
local wibox_popup = wibox({
|
||||
ontop = true,
|
||||
visible = false,
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 4)
|
||||
end,
|
||||
border_width = 1,
|
||||
border_color = beautiful.bg_focus,
|
||||
max_widget_size = 500,
|
||||
height = 500,
|
||||
width = 300,
|
||||
})
|
||||
|
||||
local apt_widget = wibox.widget {
|
||||
{
|
||||
{
|
||||
id = 'icon',
|
||||
widget = wibox.widget.imagebox
|
||||
},
|
||||
margins = 4,
|
||||
layout = wibox.container.margin
|
||||
},
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
set_icon = function(self, new_icon)
|
||||
self:get_children_by_id("icon")[1].image = new_icon
|
||||
end
|
||||
}
|
||||
local apt_widget = wibox.widget({
|
||||
{
|
||||
{
|
||||
id = "icon",
|
||||
widget = wibox.widget.imagebox,
|
||||
},
|
||||
margins = 4,
|
||||
layout = wibox.container.margin,
|
||||
},
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
set_icon = function(self, new_icon)
|
||||
self:get_children_by_id("icon")[1].image = new_icon
|
||||
end,
|
||||
})
|
||||
|
||||
local apt_widget_button = wibox.widget({
|
||||
{
|
||||
apt_widget,
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
widget = clickable_container,
|
||||
})
|
||||
|
||||
--- Parses the line and creates the package table out of it
|
||||
--- yaru-theme-sound/focal-updates,focal-updates 20.04.10.1 all [upgradable from: 20.04.8]
|
||||
local parse_package = function(line)
|
||||
local name,_,nv,type,ov = line:match('(.*)%/(.*)%s(.*)%s(.*)%s%[upgradable from: (.*)]')
|
||||
local name, _, nv, type, ov = line:match("(.*)%/(.*)%s(.*)%s(.*)%s%[upgradable from: (.*)]")
|
||||
|
||||
if name == nil then return nil end
|
||||
if name == nil then
|
||||
return nil
|
||||
end
|
||||
|
||||
local package = {
|
||||
name = name,
|
||||
new_version = nv,
|
||||
type = type,
|
||||
old_version = ov
|
||||
}
|
||||
return package
|
||||
local package = {
|
||||
name = name,
|
||||
new_version = nv,
|
||||
type = type,
|
||||
old_version = ov,
|
||||
}
|
||||
return package
|
||||
end
|
||||
|
||||
local function worker(user_args)
|
||||
local args = user_args or {}
|
||||
|
||||
local args = user_args or {}
|
||||
local icon = args.icon or ICONS_DIR .. "white-black.svg"
|
||||
|
||||
local icon = args.icon or ICONS_DIR .. 'white-black.svg'
|
||||
apt_widget:set_icon(icon)
|
||||
|
||||
apt_widget:set_icon(icon)
|
||||
local pointer = 0
|
||||
local min_widgets = 5
|
||||
local carousel = false
|
||||
|
||||
local pointer = 0
|
||||
local min_widgets = 5
|
||||
local carousel = false
|
||||
local function rebuild_widget(containers, errors, _, _)
|
||||
local to_update = {}
|
||||
|
||||
local function rebuild_widget(containers, errors, _, _)
|
||||
if errors ~= "" then
|
||||
show_warning(errors)
|
||||
return
|
||||
end
|
||||
|
||||
local to_update = {}
|
||||
local rows = wibox.layout.fixed.vertical()
|
||||
rows:connect_signal("button::press", function(_, _, _, button)
|
||||
if carousel then
|
||||
if button == 4 then -- up scrolling
|
||||
local cnt = #rows.children
|
||||
local first_widget = rows.children[1]
|
||||
rows:insert(cnt + 1, first_widget)
|
||||
rows:remove(1)
|
||||
elseif button == 5 then -- down scrolling
|
||||
local cnt = #rows.children
|
||||
local last_widget = rows.children[cnt]
|
||||
rows:insert(1, last_widget)
|
||||
rows:remove(cnt + 1)
|
||||
end
|
||||
else
|
||||
if button == 5 then -- up scrolling
|
||||
if pointer < #rows.children and ((#rows.children - pointer) >= min_widgets) then
|
||||
pointer = pointer + 1
|
||||
rows.children[pointer].visible = false
|
||||
end
|
||||
elseif button == 4 then -- down scrolling
|
||||
if pointer > 0 then
|
||||
rows.children[pointer].visible = true
|
||||
pointer = pointer - 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
if errors ~= '' then
|
||||
show_warning(errors)
|
||||
return
|
||||
end
|
||||
for line in containers:gmatch("[^\r\n]+") do
|
||||
local package = parse_package(line)
|
||||
|
||||
local rows = wibox.layout.fixed.vertical()
|
||||
rows:connect_signal("button::press", function(_,_,_,button)
|
||||
if carousel then
|
||||
if button == 4 then -- up scrolling
|
||||
local cnt = #rows.children
|
||||
local first_widget = rows.children[1]
|
||||
rows:insert(cnt+1, first_widget)
|
||||
rows:remove(1)
|
||||
elseif button == 5 then -- down scrolling
|
||||
local cnt = #rows.children
|
||||
local last_widget = rows.children[cnt]
|
||||
rows:insert(1, last_widget)
|
||||
rows:remove(cnt+1)
|
||||
end
|
||||
else
|
||||
if button == 5 then -- up scrolling
|
||||
if pointer < #rows.children and ((#rows.children - pointer) >= min_widgets) then
|
||||
pointer = pointer + 1
|
||||
rows.children[pointer].visible = false
|
||||
end
|
||||
elseif button == 4 then -- down scrolling
|
||||
if pointer > 0 then
|
||||
rows.children[pointer].visible = true
|
||||
pointer = pointer - 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
if package ~= nil then
|
||||
local refresh_button = wibox.widget({
|
||||
{
|
||||
{
|
||||
id = "icon",
|
||||
image = ICONS_DIR .. "refresh-cw.svg",
|
||||
resize = false,
|
||||
widget = wibox.widget.imagebox,
|
||||
},
|
||||
margins = 4,
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
shape = gears.shape.circle,
|
||||
opacity = 0.5,
|
||||
widget = wibox.container.background,
|
||||
})
|
||||
local old_cursor, old_wibox
|
||||
refresh_button:connect_signal("mouse::enter", function(c)
|
||||
c:set_opacity(1)
|
||||
c:emit_signal("widget::redraw_needed")
|
||||
local wb = mouse.current_wibox
|
||||
old_cursor, old_wibox = wb.cursor, wb
|
||||
wb.cursor = "hand1"
|
||||
end)
|
||||
refresh_button:connect_signal("mouse::leave", function(c)
|
||||
c:set_opacity(0.5)
|
||||
c:emit_signal("widget::redraw_needed")
|
||||
if old_wibox then
|
||||
old_wibox.cursor = old_cursor
|
||||
old_wibox = nil
|
||||
end
|
||||
end)
|
||||
|
||||
for line in containers:gmatch("[^\r\n]+") do
|
||||
local package = parse_package(line)
|
||||
local row = wibox.widget({
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
id = "checkbox",
|
||||
checked = false,
|
||||
color = beautiful.bg_normal,
|
||||
paddings = 2,
|
||||
shape = gears.shape.circle,
|
||||
forced_width = 20,
|
||||
forced_height = 20,
|
||||
check_color = beautiful.fg_urgent,
|
||||
border_color = beautiful.bg_urgent,
|
||||
border_width = 1,
|
||||
widget = wibox.widget.checkbox,
|
||||
},
|
||||
valign = "center",
|
||||
layout = wibox.container.place,
|
||||
},
|
||||
{
|
||||
{
|
||||
id = "name",
|
||||
markup = "<b>" .. package["name"] .. "</b>",
|
||||
widget = wibox.widget.textbox,
|
||||
},
|
||||
halign = "left",
|
||||
layout = wibox.container.place,
|
||||
},
|
||||
{
|
||||
refresh_button,
|
||||
halign = "right",
|
||||
valign = "center",
|
||||
fill_horizontal = true,
|
||||
layout = wibox.container.place,
|
||||
},
|
||||
spacing = 8,
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
},
|
||||
margins = 8,
|
||||
layout = wibox.container.margin,
|
||||
},
|
||||
id = "row",
|
||||
bg = beautiful.bg_normal,
|
||||
widget = wibox.container.background,
|
||||
click = function(self, checked)
|
||||
local a = self:get_children_by_id("checkbox")[1]
|
||||
if checked == nil then
|
||||
a:set_checked(not a.checked)
|
||||
else
|
||||
a:set_checked(checked)
|
||||
end
|
||||
|
||||
if package ~= nil then
|
||||
if a.checked then
|
||||
to_update[ package["name"] ] = self
|
||||
else
|
||||
to_update[ package["name"] ] = false
|
||||
end
|
||||
end,
|
||||
update = function(self)
|
||||
refresh_button:get_children_by_id("icon")[1]:set_image(ICONS_DIR .. "watch.svg")
|
||||
self:get_children_by_id("name")[1]:set_opacity(0.4)
|
||||
self:get_children_by_id("name")[1]:emit_signal("widget::redraw_needed")
|
||||
|
||||
local refresh_button = wibox.widget {
|
||||
{
|
||||
{
|
||||
id = 'icon',
|
||||
image = ICONS_DIR .. 'refresh-cw.svg',
|
||||
resize = false,
|
||||
widget = wibox.widget.imagebox
|
||||
},
|
||||
margins = 4,
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
shape = gears.shape.circle,
|
||||
opacity = 0.5,
|
||||
widget = wibox.container.background
|
||||
}
|
||||
local old_cursor, old_wibox
|
||||
refresh_button:connect_signal("mouse::enter", function(c)
|
||||
c:set_opacity(1)
|
||||
c:emit_signal('widget::redraw_needed')
|
||||
local wb = mouse.current_wibox
|
||||
old_cursor, old_wibox = wb.cursor, wb
|
||||
wb.cursor = "hand1"
|
||||
end)
|
||||
refresh_button:connect_signal("mouse::leave", function(c)
|
||||
c:set_opacity(0.5)
|
||||
c:emit_signal('widget::redraw_needed')
|
||||
if old_wibox then
|
||||
old_wibox.cursor = old_cursor
|
||||
old_wibox = nil
|
||||
end
|
||||
end)
|
||||
spawn.easy_async(
|
||||
string.format([[sh -c 'yes | aptdcon --hide-terminal -u %s']], package["name"]),
|
||||
function(stdout, stderr) -- luacheck:ignore 212
|
||||
rows:remove_widgets(self)
|
||||
end
|
||||
)
|
||||
end,
|
||||
})
|
||||
|
||||
local row = wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
id = 'checkbox',
|
||||
checked = false,
|
||||
color = beautiful.bg_normal,
|
||||
paddings = 2,
|
||||
shape = gears.shape.circle,
|
||||
forced_width = 20,
|
||||
forced_height = 20,
|
||||
check_color = beautiful.fg_urgent,
|
||||
border_color = beautiful.bg_urgent,
|
||||
border_width = 1,
|
||||
widget = wibox.widget.checkbox
|
||||
},
|
||||
valign = 'center',
|
||||
layout = wibox.container.place,
|
||||
},
|
||||
{
|
||||
{
|
||||
id = 'name',
|
||||
markup = '<b>' .. package['name'] .. '</b>',
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
halign = 'left',
|
||||
layout = wibox.container.place
|
||||
},
|
||||
{
|
||||
refresh_button,
|
||||
halign = 'right',
|
||||
valign = 'center',
|
||||
fill_horizontal = true,
|
||||
layout = wibox.container.place,
|
||||
},
|
||||
spacing = 8,
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
},
|
||||
margins = 8,
|
||||
layout = wibox.container.margin
|
||||
},
|
||||
id = 'row',
|
||||
bg = beautiful.bg_normal,
|
||||
widget = wibox.container.background,
|
||||
click = function(self, checked)
|
||||
local a = self:get_children_by_id('checkbox')[1]
|
||||
if checked == nil then
|
||||
a:set_checked(not a.checked)
|
||||
else
|
||||
a:set_checked(checked)
|
||||
end
|
||||
row:connect_signal("mouse::enter", function(c)
|
||||
c:set_bg(beautiful.bg_focus)
|
||||
end)
|
||||
row:connect_signal("mouse::leave", function(c)
|
||||
c:set_bg(beautiful.bg_normal)
|
||||
end)
|
||||
|
||||
if a.checked then
|
||||
to_update[package['name']] = self
|
||||
else
|
||||
to_update[package['name']] = false
|
||||
end
|
||||
end,
|
||||
update = function(self)
|
||||
refresh_button:get_children_by_id('icon')[1]:set_image(ICONS_DIR .. 'watch.svg')
|
||||
self:get_children_by_id('name')[1]:set_opacity(0.4)
|
||||
self:get_children_by_id('name')[1]:emit_signal('widget::redraw_needed')
|
||||
row:connect_signal("button::press", function(c, _, _, button)
|
||||
if button == 1 then
|
||||
c:click()
|
||||
end
|
||||
end)
|
||||
|
||||
spawn.easy_async(
|
||||
string.format([[sh -c 'yes | aptdcon --hide-terminal -u %s']], package['name']),
|
||||
function(stdout, stderr) -- luacheck:ignore 212
|
||||
rows:remove_widgets(self)
|
||||
end)
|
||||
refresh_button:buttons(gears.table.join(awful.button({}, 1, function()
|
||||
row:update()
|
||||
end)))
|
||||
|
||||
end
|
||||
}
|
||||
rows:add(row)
|
||||
end
|
||||
end
|
||||
|
||||
row:connect_signal("mouse::enter", function(c)
|
||||
c:set_bg(beautiful.bg_focus)
|
||||
end)
|
||||
row:connect_signal("mouse::leave", function(c)
|
||||
c:set_bg(beautiful.bg_normal)
|
||||
end)
|
||||
local header_checkbox = wibox.widget({
|
||||
checked = false,
|
||||
color = beautiful.bg_normal,
|
||||
paddings = 2,
|
||||
shape = gears.shape.circle,
|
||||
forced_width = 20,
|
||||
forced_height = 20,
|
||||
check_color = beautiful.fg_urgent,
|
||||
border_color = beautiful.bg_urgent,
|
||||
border_width = 1,
|
||||
widget = wibox.widget.checkbox,
|
||||
})
|
||||
header_checkbox:connect_signal("button::press", function(c)
|
||||
c:set_checked(not c.checked)
|
||||
local cbs = rows.children
|
||||
for _, v in ipairs(cbs) do
|
||||
v:click(c.checked)
|
||||
end
|
||||
end)
|
||||
|
||||
row:connect_signal("button::press", function(c, _, _, button)
|
||||
if button == 1 then c:click() end
|
||||
end)
|
||||
local header_refresh_icon = wibox.widget({
|
||||
image = ICONS_DIR .. "refresh-cw.svg",
|
||||
resize = false,
|
||||
widget = wibox.widget.imagebox,
|
||||
})
|
||||
header_refresh_icon:buttons(gears.table.join(awful.button({}, 1, function()
|
||||
print(#to_update)
|
||||
for _, v in pairs(to_update) do
|
||||
if v ~= nil then
|
||||
v:update()
|
||||
end
|
||||
end
|
||||
end)))
|
||||
|
||||
refresh_button:buttons(awful.util.table.join(awful.button({}, 1, function()
|
||||
row:update()
|
||||
end)))
|
||||
local header_row = wibox.widget({
|
||||
{
|
||||
{
|
||||
{
|
||||
header_checkbox,
|
||||
valign = "center",
|
||||
layout = wibox.container.place,
|
||||
},
|
||||
{
|
||||
{
|
||||
id = "name",
|
||||
markup = "<b>" .. #rows.children .. "</b> packages to update",
|
||||
widget = wibox.widget.textbox,
|
||||
},
|
||||
halign = "center",
|
||||
layout = wibox.container.place,
|
||||
},
|
||||
{
|
||||
header_refresh_icon,
|
||||
halign = "right",
|
||||
valign = "center",
|
||||
layout = wibox.container.place,
|
||||
},
|
||||
layout = wibox.layout.align.horizontal,
|
||||
},
|
||||
margins = 8,
|
||||
layout = wibox.container.margin,
|
||||
},
|
||||
bg = beautiful.bg_normal,
|
||||
widget = wibox.container.background,
|
||||
})
|
||||
|
||||
rows:add(row)
|
||||
end
|
||||
end
|
||||
wibox_popup:setup({
|
||||
header_row,
|
||||
rows,
|
||||
layout = wibox.layout.fixed.vertical,
|
||||
})
|
||||
end
|
||||
|
||||
apt_widget:buttons(gears.table.join(awful.button({}, 1, function()
|
||||
if wibox_popup.visible then
|
||||
wibox_popup.visible = not wibox_popup.visible
|
||||
else
|
||||
spawn.easy_async(LIST_PACKAGES, function(stdout, stderr)
|
||||
rebuild_widget(stdout, stderr)
|
||||
wibox_popup.visible = true
|
||||
awful.placement.top(wibox_popup, { margins = { top = 20 }, parent = mouse })
|
||||
end)
|
||||
end
|
||||
end)))
|
||||
|
||||
|
||||
local header_checkbox = wibox.widget {
|
||||
checked = false,
|
||||
color = beautiful.bg_normal,
|
||||
paddings = 2,
|
||||
shape = gears.shape.circle,
|
||||
forced_width = 20,
|
||||
forced_height = 20,
|
||||
check_color = beautiful.fg_urgent,
|
||||
border_color = beautiful.bg_urgent,
|
||||
border_width = 1,
|
||||
widget = wibox.widget.checkbox
|
||||
}
|
||||
header_checkbox:connect_signal("button::press", function(c)
|
||||
c:set_checked(not c.checked)
|
||||
local cbs = rows.children
|
||||
for _,v in ipairs(cbs) do
|
||||
v:click(c.checked)
|
||||
end
|
||||
end)
|
||||
wibox_popup:connect_signal("mouse::leave", function()
|
||||
if wibox_popup.visible then
|
||||
wibox_popup.visible = false
|
||||
end
|
||||
end)
|
||||
|
||||
local header_refresh_icon = wibox.widget {
|
||||
image = ICONS_DIR .. 'refresh-cw.svg',
|
||||
resize = false,
|
||||
widget = wibox.widget.imagebox
|
||||
}
|
||||
header_refresh_icon:buttons(awful.util.table.join(awful.button({}, 1, function()
|
||||
print(#to_update)
|
||||
for _,v in pairs(to_update) do
|
||||
if v ~= nil then
|
||||
v:update()
|
||||
end
|
||||
end
|
||||
end)))
|
||||
|
||||
local header_row = wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
header_checkbox,
|
||||
valign = 'center',
|
||||
layout = wibox.container.place,
|
||||
},
|
||||
{
|
||||
{
|
||||
id = 'name',
|
||||
markup = '<b>' .. #rows.children .. '</b> packages to update',
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
halign = 'center',
|
||||
layout = wibox.container.place
|
||||
},
|
||||
{
|
||||
header_refresh_icon,
|
||||
halign = 'right',
|
||||
valign = 'center',
|
||||
layout = wibox.container.place,
|
||||
},
|
||||
layout = wibox.layout.align.horizontal
|
||||
},
|
||||
margins = 8,
|
||||
layout = wibox.container.margin
|
||||
},
|
||||
bg = beautiful.bg_normal,
|
||||
widget = wibox.container.background
|
||||
}
|
||||
|
||||
wibox_popup:setup {
|
||||
header_row,
|
||||
rows,
|
||||
layout = wibox.layout.fixed.vertical
|
||||
}
|
||||
end
|
||||
|
||||
apt_widget:buttons(
|
||||
awful.util.table.join(
|
||||
awful.button({}, 1, function()
|
||||
if wibox_popup.visible then
|
||||
wibox_popup.visible = not wibox_popup.visible
|
||||
else
|
||||
spawn.easy_async(LIST_PACKAGES,
|
||||
function(stdout, stderr)
|
||||
rebuild_widget(stdout, stderr)
|
||||
wibox_popup.visible = true
|
||||
awful.placement.top(wibox_popup, { margins = { top = 20 }, parent = mouse})
|
||||
end)
|
||||
end
|
||||
end)
|
||||
)
|
||||
)
|
||||
|
||||
return apt_widget
|
||||
return apt_widget_button
|
||||
end
|
||||
|
||||
return setmetatable(apt_widget, { __call = function(_, ...) return worker(...) end })
|
||||
return setmetatable(apt_widget, {
|
||||
__call = function(_, ...)
|
||||
return worker(...)
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -21,19 +21,19 @@ It is possible to customize widget by providing a table with all or some of the
|
|||
|
||||
| Name | Default | Description |
|
||||
|---|---|---|
|
||||
| `font` | Play 8 | Fond |
|
||||
| `font` | `Play 8` | Font |
|
||||
| `path_to_icons` | `/usr/share/icons/Arc/status/symbolic/` | Path to the folder with icons* |
|
||||
| `show_current_level`| false | Show current charge level |
|
||||
| `margin_right`|0| The right margin of the widget|
|
||||
| `margin_left`|0| The left margin of the widget|
|
||||
| `display_notification` | `false` | Display a notification on mouseover |
|
||||
| `display_notification` | false | Display a notification on mouseover |
|
||||
| `notification_position` | `top_right` | The notification position |
|
||||
| `timeout` | 10 | How often in seconds the widget refreshes |
|
||||
| `warning_msg_title` | _Huston, we have a problem_ | Title of the warning popup |
|
||||
| `warning_msg_text` | _Battery is dying_ | Text of the warning popup |
|
||||
| `warning_msg_title` | `Huston, we have a problem` | Title of the warning popup |
|
||||
| `warning_msg_text` | `Battery is dying` | Text of the warning popup |
|
||||
| `warning_msg_position` | `bottom_right` | Position of the warning popup |
|
||||
| `warning_msg_icon` | ~/.config/awesome/awesome-wm-widgets/battery-widget/spaceman.jpg | Icon of the warning popup |
|
||||
| `enable_battery_warning` | `true` | Display low battery warning |
|
||||
| `warning_msg_icon` | `~/.config/awesome/awesome-wm-widgets/battery-widget/spaceman.jpg` | Icon of the warning popup |
|
||||
| `enable_battery_warning` | true | Display low battery warning |
|
||||
|
||||
*Note: the widget expects following icons to be present in the folder:
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ It is possible to customize widget by providing a table with all or some of the
|
|||
|
||||
| Name | Default | Description |
|
||||
|---|---|---|
|
||||
| `font` | Play 6 | Font |
|
||||
| `font` | `Play 6` | Font |
|
||||
| `arc_thickness` | 2 | Thickness of the arc |
|
||||
| `show_current_level`| false | Show current charge level |
|
||||
| `size`| 18 | Size of the widget |
|
||||
|
@ -33,11 +33,11 @@ It is possible to customize widget by providing a table with all or some of the
|
|||
| `low_level_color` | `#e53935` | Arc color when battery charge is less that 15% |
|
||||
| `medium_level_color` | `#c0ca33` | Arc color when battery charge is between 15% and 40% |
|
||||
| `charging_color` | `#43a047` | Color of the circle inside the arc when charging |
|
||||
| `warning_msg_title` | _Huston, we have a problem_ | Title of the warning popup |
|
||||
| `warning_msg_text` | _Battery is dying_ | Text of the warning popup |
|
||||
| `warning_msg_title` | `Huston, we have a problem_` | Title of the warning popup |
|
||||
| `warning_msg_text` | `Battery is dying` | Text of the warning popup |
|
||||
| `warning_msg_position` | `bottom_right` | Position of the warning popup |
|
||||
| `warning_msg_icon` | ~/.config/awesome/awesome-wm-widgets/batteryarc-widget/spaceman.jpg | Icon of the warning popup |
|
||||
| `enable_battery_warning` | `true` | Display low battery warning |
|
||||
| `warning_msg_icon` | `~/.config/awesome/awesome-wm-widgets/batteryarc-widget/spaceman.jpg` | Icon of the warning popup |
|
||||
| `enable_battery_warning` | true | Display low battery warning |
|
||||
| `show_notification_mode` | `on_hover` | How to trigger a notification with the battery status: `on_hover`, `on_click` or `off` |
|
||||
| `notification_position` | `top_left` | Where to show she notification when triggered. Values: `top_right`, `top_left`, `bottom_left`, `bottom_right`, `top_middle`, `bottom_middle`. (default `top_right`) |
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ It is possible to customize widget by providing a table with all or some of the
|
|||
| Name | Default | Description |
|
||||
|---|---|---|
|
||||
| `icon` | `~/.config/awesome/awesome-wm-widgets/bitbucket-widget/bitbucket-icon-gradient-blue.svg` | Path to the icon |
|
||||
| `host` | Required | e.g _http://api.bitbucket.org_ |
|
||||
| `uuid` | Required | e.g _{123e4567-e89b-12d3-a456-426614174000}_ |
|
||||
| `host` | Required | e.g. _http://api.bitbucket.org_ |
|
||||
| `uuid` | Required | e.g. _{123e4567-e89b-12d3-a456-426614174000}_ |
|
||||
| `workspace` | Required | Workspace ID|
|
||||
| `repo_slug` | Required | Repository slug |
|
||||
| `timeout` | 60 | How often in seconds the widget refreshes |
|
||||
|
|
|
@ -49,6 +49,6 @@ It is possible to customize the widget by providing a table with all or some of
|
|||
|---|---|---|
|
||||
| `font` | `beautiful.font` | Font name and size, like `Play 12` |
|
||||
| `path_to_icons` | `/usr/share/icons/Arc/actions/symbolic/` | Alternative path for the icons |
|
||||
| `timeout`| `10` | Refresh cooldown |
|
||||
| `max_length` | `30` | Maximum lentgh of title. Text will be ellipsized if longer. |
|
||||
| `space` | `3` | Space between icon and track title |
|
||||
| `timeout`| 10 | Refresh cooldown |
|
||||
| `max_length` | 30 | Maximum lentgh of title. Text will be ellipsized if longer. |
|
||||
| `space` | 3 | Space between icon and track title |
|
||||
|
|
|
@ -28,8 +28,8 @@ It is possible to customize widget by providing a table with all or some of the
|
|||
| `step_width` | 2 | Width of the step |
|
||||
| `step_spacing` | 1 | Space size between steps |
|
||||
| `color` | `beautiful.fg_normal` | Color of the graph |
|
||||
| `enable_kill_button` | `false` | Show button which kills the process |
|
||||
| `process_info_max_length` | `-1` | Truncate the process information. Some processes may have a very long list of parameters which won't fit in the screen, this options allows to truncate it to the given length. |
|
||||
| `enable_kill_button` | false | Show button which kills the process |
|
||||
| `process_info_max_length` | -1 | Truncate the process information. Some processes may have a very long list of parameters which won't fit in the screen, this options allows to truncate it to the given length. |
|
||||
| `timeout` | 1 | How often in seconds the widget refreshes |
|
||||
|
||||
### Example
|
||||
|
|
|
@ -14,8 +14,8 @@ local wibox = require("wibox")
|
|||
local beautiful = require("beautiful")
|
||||
local gears = require("gears")
|
||||
|
||||
local CMD = [[sh -c "grep '^cpu.' /proc/stat; ps -eo '%p|%c|%C|' -o "%mem" -o '|%a' --sort=-%cpu ]]
|
||||
.. [[| head -11 | tail -n +2"]]
|
||||
local CMD = [[sh -c "grep '^cpu.' /proc/stat; ps -eo 'pid:10,pcpu:5,pmem:5,comm:30,cmd' --sort=-pcpu ]]
|
||||
.. [[| grep -v [p]s | grep -v [g]rep | head -11 | tail -n +2"]]
|
||||
|
||||
-- A smaller command, less resource intensive, used when popup is not shown.
|
||||
local CMD_slim = [[grep --max-count=1 '^cpu.' /proc/stat]]
|
||||
|
@ -33,17 +33,9 @@ local process_rows = {
|
|||
layout = wibox.layout.fixed.vertical,
|
||||
}
|
||||
|
||||
-- Splits the string by separator
|
||||
-- @return table with separated substrings
|
||||
local function split(string_to_split, separator)
|
||||
if separator == nil then separator = "%s" end
|
||||
local t = {}
|
||||
|
||||
for str in string.gmatch(string_to_split, "([^".. separator .."]+)") do
|
||||
table.insert(t, str)
|
||||
end
|
||||
|
||||
return t
|
||||
-- Remove spaces at end and beggining of a string
|
||||
function trim(s)
|
||||
return (s:gsub("^%s*(.-)%s*$", "%1"))
|
||||
end
|
||||
|
||||
-- Checks if a string starts with a another string
|
||||
|
@ -242,13 +234,11 @@ local function worker(user_args)
|
|||
else
|
||||
if is_update == true then
|
||||
|
||||
local columns = split(line, '|')
|
||||
|
||||
local pid = columns[1]
|
||||
local comm = columns[2]
|
||||
local cpu = columns[3]
|
||||
local mem = columns[4]
|
||||
local cmd = columns[5]
|
||||
local pid = trim(string.sub(line, 1, 10))
|
||||
local cpu = trim(string.sub(line, 12, 16))
|
||||
local mem = trim(string.sub(line, 18, 22))
|
||||
local comm = trim(string.sub(line, 24, 53))
|
||||
local cmd = trim(string.sub(line, 54))
|
||||
|
||||
local kill_proccess_button = enable_kill_button and create_kill_process_button() or nil
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
# Docker Widget
|
||||
# Docker / Podman Widget
|
||||
|
||||
[![GitHub issues by-label](https://img.shields.io/github/issues-raw/streetturtle/awesome-wm-widgets/docker)](https://github.com/streetturtle/awesome-wm-widgets/labels/docker)
|
||||
![Twitter URL](https://img.shields.io/twitter/url?url=https%3A%2F%2Fgithub.com%2Fstreetturtle%2Fawesome-wm-widgets%2Fedit%2Fmaster%2Fdocker-widget)
|
||||
|
||||
The widget allows to manage docker containers, namely start/stop/pause/unpause:
|
||||
The widget allows to manage docker and podman containers, namely start/stop/pause/unpause:
|
||||
|
||||
<p align="center">
|
||||
<img src="https://github.com/streetturtle/awesome-wm-widgets/raw/master/docker-widget/docker.gif"/>
|
||||
|
@ -16,7 +16,11 @@ It is possible to customize widget by providing a table with all or some of the
|
|||
| Name | Default | Description |
|
||||
|---|---|---|
|
||||
| `icon` | `./docker-widget/icons/docker.svg` | Path to the icon |
|
||||
| `number_of_containers` | `-1` | Number of last created containers to show |
|
||||
| `number_of_containers` | -1 | Number of last created containers to show |
|
||||
| `executable_name` | `docker` | Name of the executable to use, defaults to `docker` |
|
||||
| `max_widget_width` | 270 | Maximum width of the widget before the text breaks |
|
||||
|
||||
The `executable_name` allows you to use `Podman` instead of docker. This works since `Podman` is compatible to `docker` in the sense that the syntax and command outputs are identical.
|
||||
|
||||
## Installation
|
||||
|
||||
|
|
|
@ -19,9 +19,12 @@ local HOME_DIR = os.getenv("HOME")
|
|||
local WIDGET_DIR = HOME_DIR .. '/.config/awesome/awesome-wm-widgets/docker-widget'
|
||||
local ICONS_DIR = WIDGET_DIR .. '/icons/'
|
||||
|
||||
local LIST_CONTAINERS_CMD = [[bash -c "docker container ls -a -s -n %s]]
|
||||
local LIST_CONTAINERS_CMD = [[bash -c "%s container ls -a -s -n %s]]
|
||||
.. [[ --format '{{.Names}}::{{.ID}}::{{.Image}}::{{.Status}}::{{.Size}}'"]]
|
||||
|
||||
local DOCKER_DEFAULT_STATUS_PATTERN = '(.*)::(.*)::(.*)::(%w*) (.*)::(.*)'
|
||||
local DOCKER_CREATED_STATUS_PATTERN = '(.*)::(.*)::(.*)::Created::(.*)'
|
||||
|
||||
--- Utility function to show warning messages
|
||||
local function show_warning(message)
|
||||
naughty.notify{
|
||||
|
@ -60,10 +63,16 @@ local docker_widget = wibox.widget {
|
|||
}
|
||||
|
||||
local parse_container = function(line)
|
||||
local name, id, image, status, how_long, size = line:match('(.*)::(.*)::(.*)::(%w*) (.*)::(.*)')
|
||||
local actual_status
|
||||
if status == 'Up' and how_long:find('Paused') then actual_status = 'Paused'
|
||||
else actual_status = status end
|
||||
local name, id, image, how_long, size, actual_status
|
||||
if string.find(line, '::Created::') then
|
||||
name, id, image, size = line:match(DOCKER_CREATED_STATUS_PATTERN)
|
||||
actual_status = 'Created'
|
||||
how_long = 'Never started'
|
||||
else
|
||||
name, id, image, status, how_long, size = line:match(DOCKER_DEFAULT_STATUS_PATTERN)
|
||||
if status == 'Up' and how_long:find('Paused') then actual_status = 'Paused'
|
||||
else actual_status = status end
|
||||
end
|
||||
|
||||
how_long = how_long:gsub('%s?%(.*%)%s?', '')
|
||||
|
||||
|
@ -76,13 +85,15 @@ local parse_container = function(line)
|
|||
size = size,
|
||||
is_up = function() return status == 'Up' end,
|
||||
is_paused = function() return actual_status:find('Paused') end,
|
||||
is_exited = function() return status == 'Exited' end
|
||||
is_exited = function() return status == 'Exited' end,
|
||||
is_created = function() return status == 'Created' end
|
||||
}
|
||||
return container
|
||||
end
|
||||
|
||||
local status_to_icon_name = {
|
||||
Up = ICONS_DIR .. 'play.svg',
|
||||
Created = ICONS_DIR .. 'square.svg',
|
||||
Exited = ICONS_DIR .. 'square.svg',
|
||||
Paused = ICONS_DIR .. 'pause.svg'
|
||||
}
|
||||
|
@ -93,6 +104,10 @@ local function worker(user_args)
|
|||
|
||||
local icon = args.icon or ICONS_DIR .. 'docker.svg'
|
||||
local number_of_containers = args.number_of_containers or -1
|
||||
local executable_name = args.executable_name or 'docker'
|
||||
-- 180 is the default width of the container details part of the widget and
|
||||
-- 90 is the default width of the control buttons
|
||||
local max_widget_width = args.max_widget_width or 180 + 90
|
||||
|
||||
docker_widget:set_icon(icon)
|
||||
|
||||
|
@ -122,12 +137,12 @@ local function worker(user_args)
|
|||
|
||||
|
||||
local start_stop_button
|
||||
if container.is_up() or container.is_exited() then
|
||||
if container.is_up() or container.is_exited() or container.is_created() then
|
||||
start_stop_button = wibox.widget {
|
||||
{
|
||||
{
|
||||
id = 'icon',
|
||||
image = ICONS_DIR .. (container:is_up() and 'stop-btn.svg' or 'play-btn.svg'),
|
||||
image = ICONS_DIR .. (container:is_exited() and 'play-btn.svg' or 'stop-btn.svg'),
|
||||
opacity = 0.4,
|
||||
resize = false,
|
||||
widget = wibox.widget.imagebox
|
||||
|
@ -162,16 +177,16 @@ local function worker(user_args)
|
|||
start_stop_button:buttons(
|
||||
gears.table.join( awful.button({}, 1, function()
|
||||
local command
|
||||
if container:is_up() then command = 'stop' else command = 'start' end
|
||||
if container:is_exited() then command = 'start' else command = 'stop' end
|
||||
|
||||
status_icon:set_opacity(0.2)
|
||||
status_icon:emit_signal('widget::redraw_needed')
|
||||
|
||||
spawn.easy_async('docker ' .. command .. ' ' .. container['name'], function()
|
||||
if errors ~= '' then show_warning(errors) end
|
||||
spawn.easy_async(string.format(LIST_CONTAINERS_CMD, number_of_containers),
|
||||
function(stdout, stderr)
|
||||
rebuild_widget(stdout, stderr)
|
||||
spawn.easy_async(executable_name .. ' ' .. command .. ' ' .. container['name'], function(_, stderr)
|
||||
if stderr ~= '' then show_warning(stderr) end
|
||||
spawn.easy_async(string.format(LIST_CONTAINERS_CMD, executable_name, number_of_containers),
|
||||
function(stdout, container_errors)
|
||||
rebuild_widget(stdout, container_errors)
|
||||
end)
|
||||
end)
|
||||
end) ) )
|
||||
|
@ -226,9 +241,9 @@ local function worker(user_args)
|
|||
status_icon:set_opacity(0.2)
|
||||
status_icon:emit_signal('widget::redraw_needed')
|
||||
|
||||
awful.spawn.easy_async('docker ' .. command .. ' ' .. container['name'], function(_, stderr)
|
||||
awful.spawn.easy_async(executable_name .. ' ' .. command .. ' ' .. container['name'], function(_, stderr)
|
||||
if stderr ~= '' then show_warning(stderr) end
|
||||
spawn.easy_async(string.format(LIST_CONTAINERS_CMD, number_of_containers),
|
||||
spawn.easy_async(string.format(LIST_CONTAINERS_CMD, executable_name, number_of_containers),
|
||||
function(stdout, container_errors)
|
||||
rebuild_widget(stdout, container_errors)
|
||||
end)
|
||||
|
@ -258,9 +273,9 @@ local function worker(user_args)
|
|||
}
|
||||
delete_button:buttons(
|
||||
gears.table.join( awful.button({}, 1, function()
|
||||
awful.spawn.easy_async('docker rm ' .. container['name'], function(_, rm_stderr)
|
||||
awful.spawn.easy_async(executable_name .. ' rm ' .. container['name'], function(_, rm_stderr)
|
||||
if rm_stderr ~= '' then show_warning(rm_stderr) end
|
||||
spawn.easy_async(string.format(LIST_CONTAINERS_CMD, number_of_containers),
|
||||
spawn.easy_async(string.format(LIST_CONTAINERS_CMD, executable_name, number_of_containers),
|
||||
function(lc_stdout, lc_stderr)
|
||||
rebuild_widget(lc_stdout, lc_stderr) end)
|
||||
end)
|
||||
|
@ -315,7 +330,8 @@ local function worker(user_args)
|
|||
text = container['how_long'],
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
forced_width = 180,
|
||||
-- 90 is the reserved width of the control buttons
|
||||
forced_width = max_widget_width - 90,
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
valign = 'center',
|
||||
|
@ -361,7 +377,7 @@ local function worker(user_args)
|
|||
popup.visible = not popup.visible
|
||||
else
|
||||
docker_widget:set_bg(beautiful.bg_focus)
|
||||
spawn.easy_async(string.format(LIST_CONTAINERS_CMD, number_of_containers),
|
||||
spawn.easy_async(string.format(LIST_CONTAINERS_CMD, executable_name, number_of_containers),
|
||||
function(stdout, stderr)
|
||||
rebuild_widget(stdout, stderr)
|
||||
popup:move_next_to(mouse.current_widget_geometry)
|
||||
|
|
|
@ -10,7 +10,7 @@ It is possible to customize widget by providing a table with all or some of the
|
|||
|
||||
| Name | Default | Description |
|
||||
|---|---|---|
|
||||
| `mounts` | `{'/'}` | Table with mounts to monitor, check the output from a `df` command for available options (column 'Mounted on') |
|
||||
| `mounts` | `{ '/' }` | Table with mounts to monitor, check the output from a `df` command for available options (column `Mounted on`) |
|
||||
| `timeout` | 60 | How often in seconds the widget refreshes |
|
||||
|
||||
## Installation
|
||||
|
|
|
@ -14,8 +14,8 @@ It is possible to customize widget by providing a table with all or some of the
|
|||
|
||||
| Name | Default | Description |
|
||||
|---|---|---|
|
||||
| `icon` | github.png from the widget sources | Widget icon displayed on the wibar |
|
||||
| `username` | your username | Required parameter |
|
||||
| `icon` | `github.png` from the widget sources | Widget icon displayed on the wibar |
|
||||
| `username` | Required | GitHub username |
|
||||
| `number_of_events` | 10 | Number of events to display in the list |
|
||||
|
||||
## Installation
|
||||
|
|
|
@ -15,10 +15,10 @@ It is possible to customize the widget by providing a table with all or some of
|
|||
| Name | Default | Description |
|
||||
|---|---|---|
|
||||
| `username` | `streetturtle` | GitHub username |
|
||||
| `days` | `365` | Number of days in the past, more days - wider the widget |
|
||||
| `days` | 365 | Number of days in the past, more days - wider the widget |
|
||||
| `color_of_empty_cells` | Theme's default | Color of the days with no contributions |
|
||||
| `with_border` | `true` | Should the graph contains border or not |
|
||||
| `margin_top` | `1` | Top margin |
|
||||
| `with_border` | true | Should the graph contains border or not |
|
||||
| `margin_top` | 1 | Top margin |
|
||||
| `theme` | `standard` | Color theme of the graph, see below |
|
||||
|
||||
_Note:_ widget height is 21px (7 rows of 3x3 cells). So it would look nice on the wibar of 22-24px height.
|
||||
|
|
|
@ -21,7 +21,7 @@ It is possible to customize widget by providing a table with all or some of the
|
|||
|
||||
| Name | Default | Description |
|
||||
|---|---|---|
|
||||
| `reviewer` | Required | github user login |
|
||||
| `reviewer` | Required | GitHub username |
|
||||
|
||||
## Installation
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ It is possible to customize widget by providing a table with all or some of the
|
|||
| Name | Default | Description |
|
||||
|---|---|---|
|
||||
| `icon` | `./icons/gitlab-icon.svg` | Path to the icon |
|
||||
| `host` | Required | e.g _https://gitlab.yourcompany.com_ |
|
||||
| `access_token` | Required | e.g _h2v531iYASDz6McxYk4A_ |
|
||||
| `host` | Required | e.g. `https://gitlab.yourcompany.com` |
|
||||
| `access_token` | Required | e.g. `h2v531iYASDz6McxYk4A` |
|
||||
| `timeout` | 60 | How often in seconds the widget should be refreshed |
|
||||
|
||||
_Note:_
|
||||
|
|
|
@ -18,7 +18,7 @@ It is possible to customize widget by providing a table with all or some of the
|
|||
|
||||
| Name | Default | Description |
|
||||
|---|---|---|
|
||||
| `host` | Required | Ex: _http://jira.tmnt.com_ |
|
||||
| `host` | Required | e.g. `http://jira.tmnt.com` |
|
||||
| `query` | `jql=assignee=currentuser() AND resolution=Unresolved` | JQL query |
|
||||
| `icon` | `~/.config/awesome/awesome-wm-widgets/jira-widget/jira-mark-gradient-blue.svg` | Path to the icon |
|
||||
| `timeout` | 600 | How often in seconds the widget refreshes |
|
||||
|
|
|
@ -53,13 +53,13 @@ Then
|
|||
| Name | Default | Description |
|
||||
|---|---|---|
|
||||
| `icon` | `power.svg` | If used as widget - the path to the widget's icon |
|
||||
| `icon_size` | `40` | Size of the icon |
|
||||
| `icon_margin` | `16` | Margin around the icon |
|
||||
| `icon_size` | 40 | Size of the icon |
|
||||
| `icon_margin` | 16 | Margin around the icon |
|
||||
| `bg_color` | `beautiful.bg_normal` | The color the background of the |
|
||||
| `accent_color` | `beautiful.bg_focus` | The color of the buttons |
|
||||
| `text_color` | `beautiful.fg_normal` | The color of text |
|
||||
| `label_color` | `beautiful.fg_normal` | The color of the button's label |
|
||||
| `phrases` | `{'Goodbye!'}` | The table with phrase(s) to show, if more than one provided, the phrase is chosen randomly. Leave empty (`{}`) to hide the phrase |
|
||||
| `phrases` | `{ 'Goodbye!' }` | The table with phrase(s) to show, if more than one provided, the phrase is chosen randomly. Leave empty (`{}`) to hide the phrase |
|
||||
| `hide_on_leave` | `false` | If the popup should be hidden when the mouse leaves it |
|
||||
| `onlogout` | `function() awesome.quit() end` | Function which is called when the logout button is pressed |
|
||||
| `onlock` | `function() awful.spawn.with_shell("systemctl suspend") end` | Function which is called when the lock button is pressed |
|
||||
|
|
|
@ -4,7 +4,7 @@ Music Player Daemon widget by @raphaelfournier.
|
|||
|
||||
# Prerequisite
|
||||
|
||||
Install `mpd` (Music Player Daemon itself) and `mpc` (Music Player Client - program for controlling mpd), both should be available in repo, e.g for Ubuntu:
|
||||
Install `mpd` (Music Player Daemon itself) and `mpc` (Music Player Client - program for controlling mpd), both should be available in repo, e.g. for Ubuntu:
|
||||
|
||||
```bash
|
||||
sudo apt-get install mpd mpc
|
||||
|
|
|
@ -4,7 +4,7 @@ Music Player Info widget cy @mgabs
|
|||
|
||||
# Prerequisite
|
||||
|
||||
Install `playerctl` (mpris implementation), should be available in repo, e.g for Ubuntu:
|
||||
Install `playerctl` (mpris implementation), should be available in repo, e.g. for Ubuntu:
|
||||
|
||||
```bash
|
||||
sudo apt-get install playerctl
|
||||
|
|
|
@ -5,34 +5,34 @@
|
|||
-- requires - playerctl
|
||||
-- @copyright 2020
|
||||
-------------------------------------------------
|
||||
local awful = require("awful")
|
||||
local beautiful = require("beautiful")
|
||||
local watch = require("awful.widget.watch")
|
||||
local wibox = require("wibox")
|
||||
local gears = require("gears")
|
||||
local awful = require("awful")
|
||||
local beautiful = require("beautiful")
|
||||
local watch = require("awful.widget.watch")
|
||||
local wibox = require("wibox")
|
||||
local gears = require("gears")
|
||||
|
||||
local GET_MPD_CMD = "playerctl -p %s -f '{{status}};{{xesam:artist}};{{xesam:title}}' metadata"
|
||||
local GET_MPD_CMD = "playerctl -p %s -f '{{status}};{{xesam:artist}};{{xesam:title}}' metadata"
|
||||
|
||||
local TOGGLE_MPD_CMD = "playerctl play-pause"
|
||||
local NEXT_MPD_CMD = "playerctl next"
|
||||
local PREV_MPD_CMD = "playerctl previous"
|
||||
local LIST_PLAYERS_CMD = "playerctl -l"
|
||||
local TOGGLE_MPD_CMD = "playerctl play-pause"
|
||||
local NEXT_MPD_CMD = "playerctl next"
|
||||
local PREV_MPD_CMD = "playerctl previous"
|
||||
local LIST_PLAYERS_CMD = "playerctl -l"
|
||||
|
||||
local PATH_TO_ICONS = "/usr/share/icons/Arc"
|
||||
local PAUSE_ICON_NAME = PATH_TO_ICONS .. "/actions/24/player_pause.png"
|
||||
local PLAY_ICON_NAME = PATH_TO_ICONS .. "/actions/24/player_play.png"
|
||||
local STOP_ICON_NAME = PATH_TO_ICONS .. "/actions/24/player_stop.png"
|
||||
local PATH_TO_ICONS = "/usr/share/icons/Arc"
|
||||
local PAUSE_ICON_NAME = PATH_TO_ICONS .. "/actions/24/player_pause.png"
|
||||
local PLAY_ICON_NAME = PATH_TO_ICONS .. "/actions/24/player_play.png"
|
||||
local STOP_ICON_NAME = PATH_TO_ICONS .. "/actions/24/player_stop.png"
|
||||
local LIBRARY_ICON_NAME = PATH_TO_ICONS .. "/actions/24/music-library.png"
|
||||
|
||||
local default_player = ''
|
||||
local default_player = ''
|
||||
|
||||
local icon = wibox.widget {
|
||||
local icon = wibox.widget {
|
||||
id = "icon",
|
||||
widget = wibox.widget.imagebox,
|
||||
image = PLAY_ICON_NAME
|
||||
}
|
||||
|
||||
local mpris_widget = wibox.widget{
|
||||
local mpris_widget = wibox.widget {
|
||||
{
|
||||
id = 'artist',
|
||||
widget = wibox.widget.textbox
|
||||
|
@ -61,9 +61,9 @@ local mpris_widget = wibox.widget{
|
|||
end
|
||||
}
|
||||
|
||||
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,
|
||||
ontop = true,
|
||||
visible = false,
|
||||
|
@ -77,19 +77,18 @@ local popup = awful.popup{
|
|||
|
||||
local function rebuild_popup()
|
||||
awful.spawn.easy_async(LIST_PLAYERS_CMD, function(stdout, _, _, _)
|
||||
for i = 0, #rows do rows[i]=nil end
|
||||
for i = 0, #rows do rows[i] = nil end
|
||||
for player_name in stdout:gmatch("[^\r\n]+") do
|
||||
if player_name ~='' and player_name ~=nil then
|
||||
|
||||
local checkbox = wibox.widget{
|
||||
if player_name ~= '' and player_name ~= nil then
|
||||
local checkbox = wibox.widget {
|
||||
{
|
||||
checked = player_name == default_player,
|
||||
color = beautiful.bg_normal,
|
||||
paddings = 2,
|
||||
shape = gears.shape.circle,
|
||||
forced_width = 20,
|
||||
forced_width = 20,
|
||||
forced_height = 20,
|
||||
check_color = beautiful.fg_urgent,
|
||||
check_color = beautiful.fg_urgent,
|
||||
widget = wibox.widget.checkbox
|
||||
},
|
||||
valign = 'center',
|
||||
|
@ -131,7 +130,6 @@ local function rebuild_popup()
|
|||
end
|
||||
|
||||
local function worker()
|
||||
|
||||
-- retrieve song info
|
||||
local current_song, artist, player_status
|
||||
|
||||
|
@ -148,40 +146,71 @@ local function worker()
|
|||
|
||||
if player_status == "Playing" then
|
||||
icon.image = PLAY_ICON_NAME
|
||||
widget.colors = {beautiful.widget_main_color}
|
||||
widget.colors = { beautiful.widget_main_color }
|
||||
widget:set_text(artist, current_song)
|
||||
elseif player_status == "Paused" then
|
||||
icon.image = PAUSE_ICON_NAME
|
||||
widget.colors = {beautiful.widget_main_color}
|
||||
widget.colors = { beautiful.widget_main_color }
|
||||
widget:set_text(artist, current_song)
|
||||
elseif player_status == "Stopped" then
|
||||
icon.image = STOP_ICON_NAME
|
||||
else -- no player is running
|
||||
icon.image = LIBRARY_ICON_NAME
|
||||
widget.colors = {beautiful.widget_red}
|
||||
widget.colors = { beautiful.widget_red }
|
||||
end
|
||||
end
|
||||
|
||||
mpris_widget:buttons(
|
||||
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() awful.spawn(NEXT_MPD_CMD, false) end),
|
||||
awful.button({}, 5, function() awful.spawn(PREV_MPD_CMD, false) end),
|
||||
awful.button({}, 1, function() awful.spawn(TOGGLE_MPD_CMD, false) end)
|
||||
)
|
||||
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() awful.spawn(NEXT_MPD_CMD, false) end),
|
||||
awful.button({}, 5, function() awful.spawn(PREV_MPD_CMD, false) end),
|
||||
awful.button({}, 1, function() awful.spawn(TOGGLE_MPD_CMD, false) end)
|
||||
)
|
||||
)
|
||||
|
||||
watch(string.format(GET_MPD_CMD, "'" .. default_player .. "'"), 1, update_graphic, mpris_widget)
|
||||
|
||||
return mpris_widget
|
||||
local mpris_popup = awful.widget.watch(
|
||||
"playerctl metadata --format '{{ status }}: {{ artist }} - {{ title }}\nDuration: {{ duration(position) }}/{{ duration(mpris:length) }}'",
|
||||
1,
|
||||
function(popup, stdout)
|
||||
local metadata = stdout
|
||||
if popup.visible then
|
||||
popup:get_widget().text = metadata
|
||||
popup:move_next_to(mouse.current_widget_geometry)
|
||||
end
|
||||
end,
|
||||
awful.popup {
|
||||
border_color = beautiful.border_color,
|
||||
ontop = true,
|
||||
visible = false,
|
||||
widget = wibox.widget {
|
||||
widget = wibox.widget.textbox,
|
||||
forced_height = 100,
|
||||
forced_width = 200,
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
mpris_widget:connect_signal('mouse::enter',
|
||||
function()
|
||||
mpris_popup.visible = true
|
||||
end)
|
||||
mpris_widget:connect_signal('mouse::leave',
|
||||
function()
|
||||
mpris_popup.visible = false
|
||||
end)
|
||||
--}}
|
||||
|
||||
return mpris_widget
|
||||
end
|
||||
|
||||
return setmetatable(mpris_widget, {__call = function(_, ...) return worker(...) end})
|
||||
return setmetatable(mpris_widget, { __call = function(_, ...) return worker(...) end })
|
||||
|
|
|
@ -241,7 +241,7 @@ local function worker(user_args)
|
|||
layout = wibox.container.margin
|
||||
},
|
||||
bg = _config.popup_bg_color,
|
||||
layout = wibox.widget.background
|
||||
layout = wibox.container.background
|
||||
},
|
||||
forced_width = _config.popup_width,
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
|
|
|
@ -46,10 +46,10 @@ the following config parameters:
|
|||
| Name | Default | Description |
|
||||
|---|---|---|
|
||||
| `mixer_cmd` | `pavucontrol` | command to run on middle click (e.g. a mixer program) |
|
||||
| `step` | `5` | How much the volume is raised or lowered at once (in %) |
|
||||
| `step` | 5 | How much the volume is raised or lowered at once (in %) |
|
||||
| `widget_type`| `icon_and_text`| Widget type, one of `horizontal_bar`, `vertical_bar`, `icon`, `icon_and_text`, `arc` |
|
||||
| `device` | `@DEFAULT_SINK@` | Select the device name to control |
|
||||
| `tooltip` | `false` | Display volume level in a tooltip when the mouse cursor hovers the widget |
|
||||
| `tooltip` | false | Display volume level in a tooltip when the mouse cursor hovers the widget |
|
||||
|
||||
For more details on parameters depending on the chosen widget type, please
|
||||
refer to the original Volume widget.
|
||||
|
|
|
@ -15,10 +15,10 @@ It is possible to customize widget by providing a table with all or some of the
|
|||
| `color_used` | `beautiful.bg_urgent` | Color for used RAM |
|
||||
| `color_free` | `beautiful.fg_normal` | Color for free RAM |
|
||||
| `color_buf` | `beautiful.border_color_active` | Color for buffers/cache |
|
||||
| `widget_height` | `25` | Height of the widget |
|
||||
| `widget_width` | `25` | Width of the widget |
|
||||
| `widget_show_buf` | `false` | Whether to display buffers/cache separately in the tray widget. If `false`, buffers/cache are considered free RAM. |
|
||||
| `timeout` | 1 | How often (in seconds) the widget refreshes |
|
||||
| `widget_height` | 25 | Height of the widget |
|
||||
| `widget_width` | 25 | Width of the widget |
|
||||
| `widget_show_buf` | false | Whether to display buffers/cache separately in the tray widget. If `false`, buffers/cache are considered free RAM. |
|
||||
| `timeout` | 1 | How often in seconds the widget refreshes |
|
||||
|
||||
## Installation
|
||||
|
||||
|
|
|
@ -29,10 +29,10 @@ It is possible to customize widget by providing a table with all or some of the
|
|||
| `play_icon` | `/usr/share/icons/Arc/actions/24/player_play.png` | Play icon |
|
||||
| `pause_icon` | `/usr/share/icons/Arc/actions/24/player_pause.png` | Pause icon |
|
||||
| `font` | `Play 9`| Font |
|
||||
| `dim_when_paused` | `false` | Decrease the widget opacity if spotify is paused |
|
||||
| `dim_opacity` | `0.2` | Widget's opacity when dimmed, `dim_when_paused` should be set to `true` |
|
||||
| `max_length` | `15` | Maximum lentgh of artist and title names. Text will be ellipsized if longer. |
|
||||
| `show_tooltip` | `true` | Show tooltip on hover with information about the playing song |
|
||||
| `dim_when_paused` | false | Decrease the widget opacity if spotify is paused |
|
||||
| `dim_opacity` | 0.2 | Widget's opacity when dimmed, `dim_when_paused` should be set to true |
|
||||
| `max_length` | 15 | Maximum lentgh of artist and title names. Text will be ellipsized if longer. |
|
||||
| `show_tooltip` | true | Show tooltip on hover with information about the playing song |
|
||||
| `timeout` | 1 | How often in seconds the widget refreshes |
|
||||
| `sp_bin` | `sp` | Path to the `sp` binary. Required if `sp` is not in environment PATH. |
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ It is possible to customize widget by providing a table with all or some of the
|
|||
|---|---|---|
|
||||
| `icon`| `/.config/awesome/awesome-wm-widgets/stackoverflow-widget/so-icon.svg` | Path to the icon |
|
||||
| `limit` | 5 | Number of items to show in the widget |
|
||||
| `tagged` | awesome-wm | Tag, or comma-separated tags |
|
||||
| `tagged` | `awesome-wm` | Tag, or comma-separated tags |
|
||||
| `timeout` | 300 | How often in seconds the widget refreshes |
|
||||
|
||||
## Installation
|
||||
|
|
|
@ -57,7 +57,7 @@ It is possible to customize the widget by providing a table with all or some of
|
|||
| Name | Default | Description |
|
||||
|---|---|---|
|
||||
| `mixer_cmd` | `pavucontrol` | command to run on middle click (e.g. a mixer program) |
|
||||
| `step` | `5` | How much the volume is raised or lowered at once (in %) |
|
||||
| `step` | 5 | How much the volume is raised or lowered at once (in %) |
|
||||
| `widget_type`| `icon_and_text`| Widget type, one of `horizontal_bar`, `vertical_bar`, `icon`, `icon_and_text`, `arc` |
|
||||
| `device` | `pulse` | Select the device name to control |
|
||||
|
||||
|
@ -98,11 +98,11 @@ _Note:_ if you are changing icons, the folder should contain following .svg imag
|
|||
|---|---|---|
|
||||
| `main_color` | `beautiful.fg_normal` | Color of the bar |
|
||||
| `mute_color` | `beautiful.fg_urgent` | Color of the bar when mute |
|
||||
| `bg_color` | `'#ffffff11'` | Color of the bar's background |
|
||||
| `width` | `50` | The bar width |
|
||||
| `margins` | `10` | Top and bottom margins (if your wibar is 22 px high, bar will be 2 px = 22 - 2*10) |
|
||||
| `shape` | `'bar'` | [gears.shape](https://awesomewm.org/doc/api/libraries/gears.shape.html), could be `octogon`, `hexagon`, `powerline`, etc |
|
||||
| `with_icon` | `true` | Show volume icon|
|
||||
| `bg_color` | `#ffffff11` | Color of the bar's background |
|
||||
| `width` | 50 | The bar width |
|
||||
| `margins` | 10 | Top and bottom margins (if your wibar is 22 px high, bar will be 2 px = 22 - 2*10) |
|
||||
| `shape` | `bar` | [gears.shape](https://awesomewm.org/doc/api/libraries/gears.shape.html), could be `octogon`, `hexagon`, `powerline`, etc |
|
||||
| `with_icon` | true | Show volume icon|
|
||||
|
||||
_Note:_ I didn't figure out how does the `forced_height` property of progressbar widget work (maybe it doesn't work at all), thus there is a workaround with margins.
|
||||
|
||||
|
@ -112,8 +112,8 @@ _Note:_ I didn't figure out how does the `forced_height` property of progressbar
|
|||
|---|---|---|
|
||||
| `main_color` | `beautiful.fg_normal` | Color of the bar |
|
||||
| `mute_color` | `beautiful.fg_urgent` | Color of the bar when mute |
|
||||
| `bg_color` | `'#ffffff11'` | Color of the bar's background |
|
||||
| `width` | `10` | The bar width |
|
||||
| `margins` | `20` | Top and bottom margins (if your wibar is 22 px high, bar will be 2 px = 22 - 2*10) |
|
||||
| `shape` | `'bar'` | [gears.shape](https://awesomewm.org/doc/api/libraries/gears.shape.html), could be `octogon`, `hexagon`, `powerline`, etc |
|
||||
| `with_icon` | `true` | Show volume icon|
|
||||
| `bg_color` | `#ffffff11` | Color of the bar's background |
|
||||
| `width` | 10 | The bar width |
|
||||
| `margins` | 20 | Top and bottom margins (if your wibar is 22 px high, bar will be 2 px = 22 - 2*10) |
|
||||
| `shape` | `bar` | [gears.shape](https://awesomewm.org/doc/api/libraries/gears.shape.html), could be `octogon`, `hexagon`, `powerline`, etc |
|
||||
| `with_icon` | true | Show volume icon|
|
||||
|
|
|
@ -29,11 +29,11 @@ It is possible to customize widget by providing a table with all or some of the
|
|||
| api_key | Required | Get it [here](https://openweathermap.org/appid) |
|
||||
| font_name | `beautiful.font:gsub("%s%d+$", "")` | **Name** of the font to use e.g. 'Play' |
|
||||
| both_units_widget | false | Show temperature in both units - '28°C (83°F) |
|
||||
| units | metric | `metric` for celsius, `imperial` for fahrenheit |
|
||||
| units | `metric` | `metric` for celsius, `imperial` for fahrenheit |
|
||||
| show_hourly_forecast | false | Show hourly forecase section |
|
||||
| time_format_12h |false | 12 or 24 hour format (13:00 - default or 1pm) |
|
||||
| show_daily_forecast | false | Show daily forecast section |
|
||||
| icon_pack_name | weather-underground-icons | Name of the icon pack, could be `weather-underground-icon` or `VitalyGorbachev` or create your own, more details below |
|
||||
| icon_pack_name | `weather-underground-icons` | Name of the icon pack, could be `weather-underground-icon` or `VitalyGorbachev` or create your own, more details below |
|
||||
| icons_extension | `.png` | File extension of icons in the pack |
|
||||
| timeout | 120 | How often in seconds the widget refreshes |
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@ It is possible to customize widget by providing a table with all or some of the
|
|||
| main_color | `beautiful.fg_normal` | Color of the word on odd position |
|
||||
| accent_color | `beautiful.fg_urgent` | Color of the word on even position |
|
||||
| font | `beautiful.font` | Font (`Play 20`) |
|
||||
| is_human_readable | `false` | _nine fifteen_ or _fifteen past nine_ |
|
||||
| military_time | `false` | 12 or 24 time format |
|
||||
| with_spaces | `false` | Separate words with spaces |
|
||||
| is_human_readable | false | _nine fifteen_ or _fifteen past nine_ |
|
||||
| military_time | false | 12 or 24 time format |
|
||||
| with_spaces | false | Separate words with spaces |
|
||||
|
||||
## Installation
|
||||
|
||||
|
|
Loading…
Reference in New Issue