diff --git a/apt-widget/README.md b/apt-widget/README.md new file mode 100644 index 0000000..f3ac47a --- /dev/null +++ b/apt-widget/README.md @@ -0,0 +1,27 @@ +# APT widget + +Widget which shows a list of APT packages to be updated: + +![screenshot](./screenshots/screenshot.gif) + +Features: + - scrollable list !!! (thanks to this [post](https://www.reddit.com/r/awesomewm/comments/isx89x/scrolling_a_layout_fixed_flexed_layout_widget/) of reddit) + - update single package + - update multiple packages + +## Installation + +Clone the repo under ~/.config/awesome/ folder, then in rc.lua add the following: + +```lua +local apt_widget = require("awesome-wm-widgets.apt-widget.apt-widget") + +... +s.mytasklist, -- Middle widget + { -- Right widgets + layout = wibox.layout.fixed.horizontal, + ... + apt_widget(), + ... +``` + diff --git a/experiments/apt-widget/apt-widget.lua b/apt-widget/apt-widget.lua similarity index 95% rename from experiments/apt-widget/apt-widget.lua rename to apt-widget/apt-widget.lua index 9d35b0e..2374192 100644 --- a/experiments/apt-widget/apt-widget.lua +++ b/apt-widget/apt-widget.lua @@ -5,7 +5,7 @@ -- https://github.com/streetturtle/awesome-wm-widgets/tree/master/apt-widget -- @author Pavel Makhov --- @copyright 2020 Pavel Makhov +-- @copyright 2021 Pavel Makhov ------------------------------------------------- local awful = require("awful") @@ -29,13 +29,6 @@ local function show_warning(message) text = message} end --- luacheck:ignore ellipsize -local function ellipsize(text, length) - return (text:len() > length and length > 0) - and text:sub(0, length - 3) .. '...' - or text -end - local wibox_popup = wibox { ontop = true, visible = false, @@ -64,10 +57,10 @@ local apt_widget = wibox.widget { end } ---yaru-theme-sound/focal-updates,focal-updates 20.04.10.1 all [upgradable from: 20.04.8] +--- 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) - --luacheck:ignore 211 - local name,one,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 @@ -286,8 +279,8 @@ local function worker(user_args) widget = wibox.widget.imagebox } header_refresh_icon:buttons(awful.util.table.join(awful.button({}, 1, function() - -- luacheck:ignore 213 - for i,v in pairs(to_update) do + print(#to_update) + for _,v in pairs(to_update) do if v ~= nil then v:update() end @@ -305,7 +298,7 @@ local function worker(user_args) { { id = 'name', - markup = 'APT', + markup = '' .. #rows.children .. ' packages to update', widget = wibox.widget.textbox }, halign = 'center', diff --git a/experiments/apt-widget/icons/black.svg b/apt-widget/icons/black.svg similarity index 98% rename from experiments/apt-widget/icons/black.svg rename to apt-widget/icons/black.svg index 7129432..95c8410 100644 --- a/experiments/apt-widget/icons/black.svg +++ b/apt-widget/icons/black.svg @@ -1,25 +1,25 @@ - - - - - - - - - + + + + + + + + + diff --git a/experiments/apt-widget/icons/help-circle.svg b/apt-widget/icons/help-circle.svg similarity index 100% rename from experiments/apt-widget/icons/help-circle.svg rename to apt-widget/icons/help-circle.svg diff --git a/experiments/apt-widget/icons/orange.svg b/apt-widget/icons/orange.svg similarity index 98% rename from experiments/apt-widget/icons/orange.svg rename to apt-widget/icons/orange.svg index 8d90fd2..0ec1388 100644 --- a/experiments/apt-widget/icons/orange.svg +++ b/apt-widget/icons/orange.svg @@ -1,25 +1,25 @@ - - - - - - - - - + + + + + + + + + diff --git a/experiments/apt-widget/icons/refresh-cw.svg b/apt-widget/icons/refresh-cw.svg similarity index 100% rename from experiments/apt-widget/icons/refresh-cw.svg rename to apt-widget/icons/refresh-cw.svg diff --git a/experiments/apt-widget/icons/watch.svg b/apt-widget/icons/watch.svg similarity index 100% rename from experiments/apt-widget/icons/watch.svg rename to apt-widget/icons/watch.svg diff --git a/experiments/apt-widget/icons/white-black.svg b/apt-widget/icons/white-black.svg similarity index 98% rename from experiments/apt-widget/icons/white-black.svg rename to apt-widget/icons/white-black.svg index ac36107..dc7ee55 100644 --- a/experiments/apt-widget/icons/white-black.svg +++ b/apt-widget/icons/white-black.svg @@ -1,25 +1,25 @@ - - - - - - - - - + + + + + + + + + diff --git a/experiments/apt-widget/icons/white-orange.svg b/apt-widget/icons/white-orange.svg similarity index 98% rename from experiments/apt-widget/icons/white-orange.svg rename to apt-widget/icons/white-orange.svg index f63d815..c353bb5 100644 --- a/experiments/apt-widget/icons/white-orange.svg +++ b/apt-widget/icons/white-orange.svg @@ -1,25 +1,25 @@ - - - - - - - - - + + + + + + + + + diff --git a/apt-widget/screenshots/screenshot.gif b/apt-widget/screenshots/screenshot.gif new file mode 100644 index 0000000..6ffe2aa Binary files /dev/null and b/apt-widget/screenshots/screenshot.gif differ