[docker] update readme
This commit is contained in:
parent
0973c7586e
commit
3b68a403c7
|
@ -1,3 +1,33 @@
|
||||||
# Docker Widget
|
# Docker Widget
|
||||||
|
|
||||||
The widget is in progress...
|
The widget allows to manage containers, namely start/stop/pause/unpause:
|
||||||
|
|
||||||
|
![screenshot](./docker.gif)
|
||||||
|
|
||||||
|
## Customization
|
||||||
|
|
||||||
|
It is possible to customize widget by providing a table with all or some of the following config parameters:
|
||||||
|
|
||||||
|
| Name | Default | Description |
|
||||||
|
|---|---|---|
|
||||||
|
| `icon` | `./docker-widget/icons/docker.svg` | Path to the icon |
|
||||||
|
| `number_of_containers` | `-1` | Number of last created containers to show |
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Clone the repo under **~/.config/awesome/** and add widget in **rc.lua**:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
local docker_widget = require("awesome-wm-widgets.docker-widget.docker")
|
||||||
|
...
|
||||||
|
s.mytasklist, -- Middle widget
|
||||||
|
{ -- Right widgets
|
||||||
|
layout = wibox.layout.fixed.horizontal,
|
||||||
|
...
|
||||||
|
-- default
|
||||||
|
docker_widget(),
|
||||||
|
-- customized
|
||||||
|
github_activity_widget{
|
||||||
|
number_of_containers = 5
|
||||||
|
},
|
||||||
|
```
|
Binary file not shown.
After Width: | Height: | Size: 541 KiB |
|
@ -19,7 +19,7 @@ local HOME_DIR = os.getenv("HOME")
|
||||||
local WIDGET_DIR = HOME_DIR .. '/.config/awesome/awesome-wm-widgets/docker-widget'
|
local WIDGET_DIR = HOME_DIR .. '/.config/awesome/awesome-wm-widgets/docker-widget'
|
||||||
local ICONS_DIR = WIDGET_DIR .. '/icons/'
|
local ICONS_DIR = WIDGET_DIR .. '/icons/'
|
||||||
|
|
||||||
local LIST_CONTAINERS_CMD = [[bash -c "docker container ls -a --format '{{.Names}}::{{.ID}}::{{.Image}}::{{.Status}}'"]]
|
local LIST_CONTAINERS_CMD = [[bash -c "docker container ls -a -s -n %s --format '{{.Names}}::{{.ID}}::{{.Image}}::{{.Status}}::{{.Size}}'"]]
|
||||||
|
|
||||||
--- Utility function to show warning messages
|
--- Utility function to show warning messages
|
||||||
local function show_warning(message)
|
local function show_warning(message)
|
||||||
|
@ -56,20 +56,23 @@ local docker_widget = wibox.widget {
|
||||||
}
|
}
|
||||||
|
|
||||||
local parse_container = function(line)
|
local parse_container = function(line)
|
||||||
local name, id, image, status, how_long = line:match('(.*)::(.*)::(.*)::(%w*) (.*)')
|
local name, id, image, status, how_long, size = line:match('(.*)::(.*)::(.*)::(%w*) (.*)::(.*)')
|
||||||
local actual_status
|
local actual_status
|
||||||
if status == 'Up' and how_long:find('Paused') then actual_status = 'Paused'
|
if status == 'Up' and how_long:find('Paused') then actual_status = 'Paused'
|
||||||
else actual_status = status
|
else actual_status = status end
|
||||||
end
|
|
||||||
|
how_long = how_long:gsub('%s?%(.*%)%s?', '')
|
||||||
|
-- if how_long:find('seconds') then how_long = 'less than a minute ago' end
|
||||||
|
|
||||||
local container = {
|
local container = {
|
||||||
name = name,
|
name = name,
|
||||||
id = id,
|
id = id,
|
||||||
image = image,
|
image = image,
|
||||||
status = actual_status,
|
status = actual_status,
|
||||||
how_long = how_long:gsub('%s?%(.*%)%s?', ''),
|
how_long = how_long,
|
||||||
|
size = size,
|
||||||
is_up = function() return status == 'Up' end,
|
is_up = function() return status == 'Up' end,
|
||||||
is_paused = function() return how_long:find('Paused') end,
|
is_paused = function() return actual_status:find('Paused') end,
|
||||||
is_exited = function() return status == 'Exited' end
|
is_exited = function() return status == 'Exited' end
|
||||||
}
|
}
|
||||||
return container
|
return container
|
||||||
|
@ -86,6 +89,7 @@ local function worker(args)
|
||||||
local args = args or {}
|
local args = args or {}
|
||||||
|
|
||||||
local icon = args.icon or ICONS_DIR .. 'docker.svg'
|
local icon = args.icon or ICONS_DIR .. 'docker.svg'
|
||||||
|
local number_of_containers = args.num_of_containers or -1
|
||||||
|
|
||||||
docker_widget:set_icon(icon)
|
docker_widget:set_icon(icon)
|
||||||
|
|
||||||
|
@ -199,18 +203,26 @@ local function worker(args)
|
||||||
|
|
||||||
local row = wibox.widget {
|
local row = wibox.widget {
|
||||||
{
|
{
|
||||||
|
{
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
status_icon,
|
status_icon,
|
||||||
margins = 8,
|
margins = 8,
|
||||||
layout = wibox.container.margin
|
layout = wibox.container.margin
|
||||||
},
|
},
|
||||||
|
valigh = 'center',
|
||||||
|
layout = wibox.container.place
|
||||||
|
},
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
markup = '<b>' .. container['name'] .. '</b>',
|
markup = '<b>' .. container['name'] .. '</b>',
|
||||||
widget = wibox.widget.textbox
|
widget = wibox.widget.textbox
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
text = container['size'],
|
||||||
|
widget = wibox.widget.textbox
|
||||||
|
},
|
||||||
{
|
{
|
||||||
text = container['how_long'],
|
text = container['how_long'],
|
||||||
widget = wibox.widget.textbox
|
widget = wibox.widget.textbox
|
||||||
|
@ -258,7 +270,7 @@ 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(LIST_CONTAINERS_CMD, function(stdout, stderr)
|
spawn.easy_async(string.format(LIST_CONTAINERS_CMD, number_of_containers), function(stdout, stderr)
|
||||||
rebuild_widget(stdout, stderr)
|
rebuild_widget(stdout, stderr)
|
||||||
popup:move_next_to(mouse.current_widget_geometry)
|
popup:move_next_to(mouse.current_widget_geometry)
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Reference in New Issue