Skip to content

Commit

Permalink
[apt] new widget
Browse files Browse the repository at this point in the history
  • Loading branch information
streetturtle committed May 6, 2021
1 parent fbd696d commit 8929269
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 114 deletions.
27 changes: 27 additions & 0 deletions apt-widget/README.md
Original file line number Diff line number Diff line change
@@ -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(),
...
```

Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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,
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -305,7 +298,7 @@ local function worker(user_args)
{
{
id = 'name',
markup = '<b>APT</b>',
markup = '<b>' .. #rows.children .. '</b> packages to update',
widget = wibox.widget.textbox
},
halign = 'center',
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 8929269

Please sign in to comment.