From f1a52b87703658b448f830abdb3902db4474dbd1 Mon Sep 17 00:00:00 2001 From: streetturtle Date: Sat, 15 Aug 2020 22:40:15 -0400 Subject: [PATCH] [docker] awesome improvements --- docker-widget/docker.lua | 85 +++++++++++++++++------------ docker-widget/icons/docker.svg | 2 +- docker-widget/icons/pause-btn.svg | 10 ++++ docker-widget/icons/pause.svg | 16 ++++++ docker-widget/icons/play-btn.svg | 9 +++ docker-widget/icons/play.svg | 15 +++++ docker-widget/icons/square.svg | 15 +++++ docker-widget/icons/stop-btn.svg | 10 ++++ docker-widget/icons/unpause-btn.svg | 10 ++++ 9 files changed, 136 insertions(+), 36 deletions(-) create mode 100644 docker-widget/icons/pause-btn.svg create mode 100644 docker-widget/icons/pause.svg create mode 100644 docker-widget/icons/play-btn.svg create mode 100644 docker-widget/icons/play.svg create mode 100644 docker-widget/icons/square.svg create mode 100644 docker-widget/icons/stop-btn.svg create mode 100644 docker-widget/icons/unpause-btn.svg diff --git a/docker-widget/docker.lua b/docker-widget/docker.lua index 2f3aadb..3bf92b4 100644 --- a/docker-widget/docker.lua +++ b/docker-widget/docker.lua @@ -83,9 +83,9 @@ local parse_container = function(line) end local status_to_icon_name = { - Up = '/usr/share/icons/Arc/actions/16/media-playback-start.png', - Exited = '/usr/share/icons/Arc/actions/16/media-playback-stop.png', - Paused = '/usr/share/icons/Arc/actions/16/media-playback-pause.png' + Up = ICONS_DIR .. 'play.svg', + Exited = ICONS_DIR .. 'square.svg', + Paused = ICONS_DIR .. 'pause.svg' } 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 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, + opacity = 0.4, resize = false, 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 { - 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(), + opacity = 0.4, resize = false, 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( - awful.util.table.join( awful.button({}, 1, function() - local command - if container:is_up() then command = 'stop' else command = 'start' 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) ) ) - - 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 status_icon = wibox.widget { + image = status_to_icon_name[container['status']], + resize = false, + widget = wibox.widget.imagebox + } local row = wibox.widget { { { { - { - image = status_to_icon_name[container['status']], - resize = false, - widget = wibox.widget.imagebox - }, + status_icon, margins = 8, layout = wibox.container.margin }, { { - text = container['name'], + markup = '' .. container['name'] .. '', widget = wibox.widget.textbox }, { text = container['how_long'], widget = wibox.widget.textbox }, - forced_width = 160, + forced_width = 180, layout = wibox.layout.fixed.vertical }, { @@ -201,6 +185,37 @@ local function worker(args) 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::leave", function(c) c:set_bg(beautiful.bg_normal) end) diff --git a/docker-widget/icons/docker.svg b/docker-widget/icons/docker.svg index 1ce61b3..468ce94 100644 --- a/docker-widget/icons/docker.svg +++ b/docker-widget/icons/docker.svg @@ -1 +1 @@ - \ No newline at end of file +Docker icon diff --git a/docker-widget/icons/pause-btn.svg b/docker-widget/icons/pause-btn.svg new file mode 100644 index 0000000..ac2900b --- /dev/null +++ b/docker-widget/icons/pause-btn.svg @@ -0,0 +1,10 @@ + + + + \ No newline at end of file diff --git a/docker-widget/icons/pause.svg b/docker-widget/icons/pause.svg new file mode 100644 index 0000000..33f1ad2 --- /dev/null +++ b/docker-widget/icons/pause.svg @@ -0,0 +1,16 @@ + + + + + \ No newline at end of file diff --git a/docker-widget/icons/play-btn.svg b/docker-widget/icons/play-btn.svg new file mode 100644 index 0000000..455a61d --- /dev/null +++ b/docker-widget/icons/play-btn.svg @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/docker-widget/icons/play.svg b/docker-widget/icons/play.svg new file mode 100644 index 0000000..4f0ee04 --- /dev/null +++ b/docker-widget/icons/play.svg @@ -0,0 +1,15 @@ + + + + \ No newline at end of file diff --git a/docker-widget/icons/square.svg b/docker-widget/icons/square.svg new file mode 100644 index 0000000..d8424d1 --- /dev/null +++ b/docker-widget/icons/square.svg @@ -0,0 +1,15 @@ + + + + \ No newline at end of file diff --git a/docker-widget/icons/stop-btn.svg b/docker-widget/icons/stop-btn.svg new file mode 100644 index 0000000..f676d01 --- /dev/null +++ b/docker-widget/icons/stop-btn.svg @@ -0,0 +1,10 @@ + + + + diff --git a/docker-widget/icons/unpause-btn.svg b/docker-widget/icons/unpause-btn.svg new file mode 100644 index 0000000..db5b25f --- /dev/null +++ b/docker-widget/icons/unpause-btn.svg @@ -0,0 +1,10 @@ + + + + \ No newline at end of file