[apt] new widget

This commit is contained in:
streetturtle 2021-05-05 22:16:08 -04:00
parent fbd696d5f2
commit 892926936c
10 changed files with 134 additions and 114 deletions

27
apt-widget/README.md Normal file
View File

@ -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(),
...
```

View File

@ -5,7 +5,7 @@
-- https://github.com/streetturtle/awesome-wm-widgets/tree/master/apt-widget -- https://github.com/streetturtle/awesome-wm-widgets/tree/master/apt-widget
-- @author Pavel Makhov -- @author Pavel Makhov
-- @copyright 2020 Pavel Makhov -- @copyright 2021 Pavel Makhov
------------------------------------------------- -------------------------------------------------
local awful = require("awful") local awful = require("awful")
@ -29,13 +29,6 @@ local function show_warning(message)
text = message} text = message}
end 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 { local wibox_popup = wibox {
ontop = true, ontop = true,
visible = false, visible = false,
@ -64,10 +57,10 @@ local apt_widget = wibox.widget {
end 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) local parse_package = function(line)
--luacheck:ignore 211 local name,_,nv,type,ov = line:match('(.*)%/(.*)%s(.*)%s(.*)%s%[upgradable from: (.*)]')
local name,one,nv,type,ov = line:match('(.*)%/(.*)%s(.*)%s(.*)%s%[upgradable from: (.*)]')
if name == nil then return nil end if name == nil then return nil end
@ -286,8 +279,8 @@ local function worker(user_args)
widget = wibox.widget.imagebox widget = wibox.widget.imagebox
} }
header_refresh_icon:buttons(awful.util.table.join(awful.button({}, 1, function() header_refresh_icon:buttons(awful.util.table.join(awful.button({}, 1, function()
-- luacheck:ignore 213 print(#to_update)
for i,v in pairs(to_update) do for _,v in pairs(to_update) do
if v ~= nil then if v ~= nil then
v:update() v:update()
end end
@ -305,7 +298,7 @@ local function worker(user_args)
{ {
{ {
id = 'name', id = 'name',
markup = '<b>APT</b>', markup = '<b>' .. #rows.children .. '</b> packages to update',
widget = wibox.widget.textbox widget = wibox.widget.textbox
}, },
halign = 'center', halign = 'center',

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 365 B

After

Width:  |  Height:  |  Size: 365 B

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 395 B

After

Width:  |  Height:  |  Size: 395 B

View File

Before

Width:  |  Height:  |  Size: 457 B

After

Width:  |  Height:  |  Size: 457 B

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 682 KiB