[docker] awesome

improvements
This commit is contained in:
streetturtle 2020-08-15 22:40:15 -04:00
parent 1310031b3a
commit f1a52b8770
9 changed files with 136 additions and 36 deletions

View File

@ -83,9 +83,9 @@ local parse_container = function(line)
end end
local status_to_icon_name = { local status_to_icon_name = {
Up = '/usr/share/icons/Arc/actions/16/media-playback-start.png', Up = ICONS_DIR .. 'play.svg',
Exited = '/usr/share/icons/Arc/actions/16/media-playback-stop.png', Exited = ICONS_DIR .. 'square.svg',
Paused = '/usr/share/icons/Arc/actions/16/media-playback-pause.png' Paused = ICONS_DIR .. 'pause.svg'
} }
local function worker(args) local function worker(args)
@ -119,65 +119,49 @@ local function worker(args)
if status == 'Up' or 'Exited' then is_visible = true else is_visible = false end if status == 'Up' or 'Exited' then is_visible = true else is_visible = false end
local start_stop_button = wibox.widget { local start_stop_button = wibox.widget {
image = container:is_up() and '/usr/share/icons/Arc/actions/16/media-playback-stop.png' or '/usr/share/icons/Arc/actions/16/media-playback-start.png', image = ICONS_DIR .. (container:is_up() and 'stop-btn.svg' or 'play-btn.svg'),
visible = is_visible, visible = is_visible,
opacity = 0.4,
resize = false, resize = false,
widget = wibox.widget.imagebox widget = wibox.widget.imagebox
} }
start_stop_button:connect_signal("mouse::enter", function(c) c:set_opacity(1) c:emit_signal('widget::redraw_needed') end)
start_stop_button:connect_signal("mouse::leave", function(c) c:set_opacity(0.4) c:emit_signal('widget::redraw_needed') end)
local pause_unpause_button = wibox.widget { local pause_unpause_button = wibox.widget {
image = container:is_up() and '/usr/share/icons/Arc/actions/16/media-playback-pause.png' or '/usr/share/icons/Arc/actions/16/media-skip-forward.png', image = ICONS_DIR .. (container:is_paused() and 'unpause-btn.svg' or 'pause-btn.svg'),
visible = container.is_up(), visible = container.is_up(),
opacity = 0.4,
resize = false, resize = false,
widget = wibox.widget.imagebox widget = wibox.widget.imagebox
} }
pause_unpause_button:connect_signal("mouse::enter", function(c) c:set_opacity(1) c:emit_signal('widget::redraw_needed') end)
pause_unpause_button:connect_signal("mouse::leave", function(c) c:set_opacity(0.4) c:emit_signal('widget::redraw_needed') end)
start_stop_button:buttons( local status_icon = wibox.widget {
awful.util.table.join( awful.button({}, 1, function() image = status_to_icon_name[container['status']],
local command resize = false,
if container:is_up() then command = 'stop' else command = 'start' end widget = wibox.widget.imagebox
}
awful.spawn.easy_async('docker ' .. command .. ' ' .. container['name'], function(stdout, stderr)
if stderr ~= '' then show_warning(stderr) return end
spawn.easy_async([[bash -c "docker container ls -a --format '{{.Names}}::{{.ID}}::{{.Image}}::{{.Status}}'"]], function(stdout, stderr)
rebuild_widget(stdout, stderr) end)
end)
end) ) )
pause_unpause_button:buttons(
awful.util.table.join( awful.button({}, 1, function()
local command
if container:is_paused() then command = 'unpause' else command = 'pause' end
awful.spawn.easy_async('docker ' .. command .. ' ' .. container['name'], function(stdout, stderr)
if stderr ~= '' then show_warning(stderr) return end
spawn.easy_async([[bash -c "docker container ls -a --format '{{.Names}}::{{.ID}}::{{.Image}}::{{.Status}}'"]], function(stdout, stderr)
rebuild_widget(stdout, stderr) end)
end)
end) ) )
local row = wibox.widget { local row = wibox.widget {
{ {
{ {
{ {
{ status_icon,
image = status_to_icon_name[container['status']],
resize = false,
widget = wibox.widget.imagebox
},
margins = 8, margins = 8,
layout = wibox.container.margin layout = wibox.container.margin
}, },
{ {
{ {
text = container['name'], markup = '<b>' .. container['name'] .. '</b>',
widget = wibox.widget.textbox widget = wibox.widget.textbox
}, },
{ {
text = container['how_long'], text = container['how_long'],
widget = wibox.widget.textbox widget = wibox.widget.textbox
}, },
forced_width = 160, forced_width = 180,
layout = wibox.layout.fixed.vertical layout = wibox.layout.fixed.vertical
}, },
{ {
@ -201,6 +185,37 @@ local function worker(args)
widget = wibox.container.background widget = wibox.container.background
} }
start_stop_button:buttons(
awful.util.table.join( awful.button({}, 1, function()
local command
if container:is_up() then command = 'stop' else command = 'start' end
status_icon:set_opacity(0.2)
status_icon:emit_signal('widget::redraw_needed')
awful.spawn.easy_async('docker ' .. command .. ' ' .. container['name'], function(stdout, stderr)
if stderr ~= '' then show_warning(stderr) return end
spawn.easy_async([[bash -c "docker container ls -a --format '{{.Names}}::{{.ID}}::{{.Image}}::{{.Status}}'"]], function(stdout, stderr)
rebuild_widget(stdout, stderr) end)
end)
end) ) )
pause_unpause_button:buttons(
awful.util.table.join( awful.button({}, 1, function()
local command
if container:is_paused() then command = 'unpause' else command = 'pause' end
status_icon:set_opacity(0.2)
status_icon:emit_signal('widget::redraw_needed')
awful.spawn.easy_async('docker ' .. command .. ' ' .. container['name'], function(stdout, stderr)
if stderr ~= '' then show_warning(stderr) return end
spawn.easy_async([[bash -c "docker container ls -a --format '{{.Names}}::{{.ID}}::{{.Image}}::{{.Status}}'"]], function(stdout, stderr)
rebuild_widget(stdout, stderr) end)
end)
end) ) )
row:connect_signal("mouse::enter", function(c) c:set_bg(beautiful.bg_focus) 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) row:connect_signal("mouse::leave", function(c) c:set_bg(beautiful.bg_normal) end)

View File

@ -1 +1 @@
<svg aria-hidden="true" focusable="false" data-prefix="fab" data-icon="docker" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512" class="svg-inline--fa fa-docker fa-w-20 fa-2x"><path fill="#0db7ed" d="M349.9 236.3h-66.1v-59.4h66.1v59.4zm0-204.3h-66.1v60.7h66.1V32zm78.2 144.8H362v59.4h66.1v-59.4zm-156.3-72.1h-66.1v60.1h66.1v-60.1zm78.1 0h-66.1v60.1h66.1v-60.1zm276.8 100c-14.4-9.7-47.6-13.2-73.1-8.4-3.3-24-16.7-44.9-41.1-63.7l-14-9.3-9.3 14c-18.4 27.8-23.4 73.6-3.7 103.8-8.7 4.7-25.8 11.1-48.4 10.7H2.4c-8.7 50.8 5.8 116.8 44 162.1 37.1 43.9 92.7 66.2 165.4 66.2 157.4 0 273.9-72.5 328.4-204.2 21.4.4 67.6.1 91.3-45.2 1.5-2.5 6.6-13.2 8.5-17.1l-13.3-8.9zm-511.1-27.9h-66v59.4h66.1v-59.4zm78.1 0h-66.1v59.4h66.1v-59.4zm78.1 0h-66.1v59.4h66.1v-59.4zm-78.1-72.1h-66.1v60.1h66.1v-60.1z" class="" data-darkreader-inline-fill="" style="--darkreader-inline-fill:currentColor;"></path></svg> <svg role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>Docker icon</title><path fill="#D8DEE9" d="M13.983 11.078h2.119a.186.186 0 00.186-.185V9.006a.186.186 0 00-.186-.186h-2.119a.185.185 0 00-.185.185v1.888c0 .102.083.185.185.185m-2.954-5.43h2.118a.186.186 0 00.186-.186V3.574a.186.186 0 00-.186-.185h-2.118a.185.185 0 00-.185.185v1.888c0 .102.082.185.185.185m0 2.716h2.118a.187.187 0 00.186-.186V6.29a.186.186 0 00-.186-.185h-2.118a.185.185 0 00-.185.185v1.887c0 .102.082.185.185.186m-2.93 0h2.12a.186.186 0 00.184-.186V6.29a.185.185 0 00-.185-.185H8.1a.185.185 0 00-.185.185v1.887c0 .102.083.185.185.186m-2.964 0h2.119a.186.186 0 00.185-.186V6.29a.185.185 0 00-.185-.185H5.136a.186.186 0 00-.186.185v1.887c0 .102.084.185.186.186m5.893 2.715h2.118a.186.186 0 00.186-.185V9.006a.186.186 0 00-.186-.186h-2.118a.185.185 0 00-.185.185v1.888c0 .102.082.185.185.185m-2.93 0h2.12a.185.185 0 00.184-.185V9.006a.185.185 0 00-.184-.186h-2.12a.185.185 0 00-.184.185v1.888c0 .102.083.185.185.185m-2.964 0h2.119a.185.185 0 00.185-.185V9.006a.185.185 0 00-.184-.186h-2.12a.186.186 0 00-.186.186v1.887c0 .102.084.185.186.185m-2.92 0h2.12a.185.185 0 00.184-.185V9.006a.185.185 0 00-.184-.186h-2.12a.185.185 0 00-.184.185v1.888c0 .102.082.185.185.185M23.763 9.89c-.065-.051-.672-.51-1.954-.51-.338.001-.676.03-1.01.087-.248-1.7-1.653-2.53-1.716-2.566l-.344-.199-.226.327c-.284.438-.49.922-.612 1.43-.23.97-.09 1.882.403 2.661-.595.332-1.55.413-1.744.42H.751a.751.751 0 00-.75.748 11.376 11.376 0 00.692 4.062c.545 1.428 1.355 2.48 2.41 3.124 1.18.723 3.1 1.137 5.275 1.137.983.003 1.963-.086 2.93-.266a12.248 12.248 0 003.823-1.389c.98-.567 1.86-1.288 2.61-2.136 1.252-1.418 1.998-2.997 2.553-4.4h.221c1.372 0 2.215-.549 2.68-1.009.309-.293.55-.65.707-1.046l.098-.288Z"/></svg>

Before

Width:  |  Height:  |  Size: 903 B

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -0,0 +1,10 @@
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path d="M11 7H8V17H11V7Z" fill="#D8DEE9" />
<path d="M13 17H16V7H13V17Z" fill="#D8DEE9" />
</svg>

After

Width:  |  Height:  |  Size: 209 B

View File

@ -0,0 +1,16 @@
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path d="M9 9H11V15H9V9Z" fill="#EBCB8B" />
<path d="M15 15H13V9H15V15Z" fill="#EBCB8B" />
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M23 12C23 18.0751 18.0751 23 12 23C5.92487 23 1 18.0751 1 12C1 5.92487 5.92487 1 12 1C18.0751 1 23 5.92487 23 12ZM21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z"
fill="#EBCB8B"
/>
</svg>

After

Width:  |  Height:  |  Size: 523 B

View File

@ -0,0 +1,9 @@
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path d="M15 12.3301L9 16.6603L9 8L15 12.3301Z" fill="#D8DEE9" />
</svg>

After

Width:  |  Height:  |  Size: 181 B

View File

@ -0,0 +1,15 @@
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21ZM12 23C18.0751 23 23 18.0751 23 12C23 5.92487 18.0751 1 12 1C5.92487 1 1 5.92487 1 12C1 18.0751 5.92487 23 12 23Z"
fill="#A3BE8C"
/>
<path d="M16 12L10 16.3301V7.66987L16 12Z" fill="#A3BE8C" />
</svg>

After

Width:  |  Height:  |  Size: 491 B

View File

@ -0,0 +1,15 @@
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path d="M15 9H9V15H15V9Z" fill="#BF616A" />
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M23 12C23 18.0751 18.0751 23 12 23C5.92487 23 1 18.0751 1 12C1 5.92487 5.92487 1 12 1C18.0751 1 23 5.92487 23 12ZM21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z"
fill="#BF616A"
/>
</svg>

After

Width:  |  Height:  |  Size: 475 B

View File

@ -0,0 +1,10 @@
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path d="M7 7H17V17H7V7Z" fill="#D8DEE9" />
</svg>

After

Width:  |  Height:  |  Size: 161 B

View File

@ -0,0 +1,10 @@
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path d="M6 17L14 12L6 7V17Z" fill="#D8DEE9" />
<path d="M18 7H15V12V17H18V7Z" fill="#D8DEE9" />
</svg>

After

Width:  |  Height:  |  Size: 214 B