You are not logged in.

#1 2023-03-12 07:43:19

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,560
Website

A package update notifier?

This discussion came up before, starting around here: https://forums.bunsenlabs.org/viewtopic … 63#p124163
then here: https://forums.bunsenlabs.org/viewtopic … 98#p124198 and following.

We generally agreed that an automatic upgrader would not be welcome, but something to notify when upgrades are available might be.

To test out that basic idea, a while ago I installed package-update-indicator.
It puts an icon in the system tray, usually black but it turns white when there are upgrades available.
Right-click "Preferences" and you can set how often the repos will be checked (I stayed with the default "daily"), and what command to run to install updates. Instead of some auto-upgrader I wrote in this:

/usr/bin/x-terminal-emulator -e sh -c 'apt list --upgradeable; bash;'

so when upgrades are available (the icon changes colour and a notification goes up) and you click "install updates" it opens a terminal window showing the packages, and then gives you a regular bash prompt to do whatever you want. Usually I run 'sudo apt upgrade' but depending on the packages you don't have to do that.

Give it a try if you're interested. I'm not suggesting BL should use this - it claims to be a "small utility" but depends on packagekit - but it's an example of what we might aim for.

I've looked at MX's apt-notifier too, but that looks a bit over the top to me, though might have some ideas we can steal.

So, I think there are four elements we need:

1) How to regularly automatically run 'apt update'. That might be as simple as adding

APT::Periodic::Update-Package-Lists "1";

to a file in /etc/apt/apt.conf.d. I've just tried this in a Boron VM, so in a day or two we'll know if it's bringing in the updates by itself.

2) How to check the new apt status (eg grepping 'apt list --upgradeable' or something more elegant).

3) How to display the news to the user: a systray icon, a tint2 button or executor, a notification popup, or conky, or a combination. If it's a systray icon, whether to display it all the time, or only if there are updates.

4) How to get user input - I like the idea of the terminal above.

Any suggestions/comments welcome!

Last edited by johnraff (2023-03-13 01:57:31)


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#2 2023-03-12 07:59:32

or1o9
Member
Registered: 2017-11-15
Posts: 246

Re: A package update notifier?

@johnraff - check link for "package-update-indicator", it just takes you to the same "Distro hoppers .." as previous link.

Edit; fixed, thanks. Will think about it.

Last edited by or1o9 (2023-03-13 04:19:16)

Offline

#3 2023-03-13 00:21:16

hhh
Gaucho
From: High in the Custerdome
Registered: 2015-09-17
Posts: 16,039
Website

Re: A package update notifier?

orionH wrote:

@johnraff - check link for "package-update-indicator", it just takes you to the same "Distro hoppers .." as previous link.

https://packages.debian.org/bullseye/pa … -indicator

https://packages.debian.org/bookworm/pa … -indicator


No, he can't sleep on the floor. What do you think I'm yelling for?!!!

Offline

#4 2023-03-13 01:58:51

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,560
Website

Re: A package update notifier?

That's the one indeed - thanks both!
Link in post fixed.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#5 2023-03-16 09:26:26

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,560
Website

Re: A package update notifier?

johnraff wrote:

How to regularly automatically run 'apt update'. That might be as simple as adding

APT::Periodic::Update-Package-Lists "1";

to a file in /etc/apt/apt.conf.d. I've just tried this in a Boron VM, so in a day or two we'll know if it's bringing in the updates by itself.

And, the answer is: yes it is! cool
After a couple of days, I now see:

john@bookworm-tmp:~$ apt list --upgradeable
Listing... Done
gir1.2-gtk-3.0/testing 3.24.37-2 amd64 [upgradable from: 3.24.36-4]
groff-base/testing 1.22.4-10 amd64 [upgradable from: 1.22.4-9]
gtk-update-icon-cache/testing 3.24.37-2 amd64 [upgradable from: 3.24.36-4]
libgtk-3-0/testing 3.24.37-2 amd64 [upgradable from: 3.24.36-4]
libgtk-3-common/testing 3.24.37-2 all [upgradable from: 3.24.36-4]
man-db/testing 2.11.2-2 amd64 [upgradable from: 2.11.2-1]
micro/testing 2.0.11-1+b1 amd64 [upgradable from: 2.0.11-1]

So the simplest thing would be to display that in Conky, in red I guess.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#6 2023-03-16 12:26:21

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,740

Re: A package update notifier?

Various tests from 2017 (targeting tint2),
https://brontosaurusrex.github.io/2017/ … w-updates/
I'am assuming some of this would work with the new

APT::Periodic::Update-Package-Lists "1";

Last edited by brontosaurusrex (2023-03-16 12:27:33)

Online

#7 2023-03-16 20:16:28

dhalgren
Member
Registered: 2015-10-01
Posts: 152

Re: A package update notifier?

I always have found little notifications of this variety annoying. I see no reason why I would want it now. Post-install  option?

Offline

#8 2023-03-17 04:13:47

sleekmason
zoom
Registered: 2018-05-22
Posts: 1,103
Website

Re: A package update notifier?

The line works well.

Made a simple executor script to change a tint2 icon out based in part on brontos work above. Using a green colored icon for when updates are available. Looks like a bunch of ways to have the notification.  What fun.

#!/bin/bash

iconpath="$HOME/.config/tint2/executors/icons/update/"
# status=$(apt list --upgradable | expr "$(wc -l)" - 1)
# apt list --upgradable minus any held packages:
status=$(( $(apt list --upgradable 2>/dev/null | wc -l ) - $( apt-mark showhold | wc -l ) -1 ))
if [ "$status" != 0 ]; then
    echo "${iconpath}upgrade-yes.png"
else
    echo "${iconpath}upgrade-no.png"
fi 

*edit - status line changed to reflect total upgradable with held packages. Thanks @johnraff

Last edited by sleekmason (2023-03-21 13:39:06)

Offline

#9 2023-03-17 04:43:33

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,560
Website

Re: A package update notifier?

dhalgren wrote:

I always have found little notifications of this variety annoying.

Yes, our users seem clearly divided on this.

We had a long discussion in 2017: https://forums.bunsenlabs.org/viewtopic.php?id=4067

Clearly not a great deal of support for installing unattended-upgrades, even disabled by default.

Let's be clear: nobody right now is thinking of enabling automatic upgrades. Too dangerous and takes too much control from the user, for BunsenLabs anyway.

But maybe 50% of users would like a reminder that upgrades are available, without having to remember to open a terminal and run the apt commands everyday. The other 50% would not want those reminders.

I'm thinking we'll need to make a package bunsen-checkupdates or the like, that users will be prompted to install - or not - when running bl-welcome. If it's installed it will put this setting in apt configs:

APT::Periodic::Update-Package-Lists "1";

NOTE this will not trigger any upgrades, it will access the apt repos once a day (the "1" at the end) and update the local data.

Then the package will need to check that data, probably via

apt list --upgradeable

and if there are updates, tell the user.

sleekmason wrote:

Looks like a bunch of ways to have the notification.  What fun.

Yes!

If we want a way that doesn't involve editing the user's personal tint2 or conky configs, what remains seems to be a system tray icon (yad can do those) and a notify-send popup. Or even a yad window, though that's more intrusive because it has to be closed. A complication is whether the script runs as the user or as root (hopefully as user), and how to make it run? Drop a .desktop file in /etc/xdg/autostart? That can be done by the package when installed, and doesn't require the user to edit their autostart script.

Then, get the monitor to run as a daemon - OK if it's not using too much RAM. Or possibly a systemd timer? Non-systemd users won't like that. Or just run it once per session? OK as long as user restarts sometimes...

So, lots of fun options. smile

Last edited by johnraff (2023-03-17 04:46:14)


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#10 2023-03-18 08:42:00

or1o9
Member
Registered: 2017-11-15
Posts: 246

Re: A package update notifier?

johnraff wrote:

I'm thinking we'll need to make a package bunsen-checkupdates or the like, that users will be prompted to install - or not - when running bl-welcome.

Yes, an excellent way of solving this idea. Personally I have no need for it since I have a very regular flow of doing an update & upgrade. But I know that there are those who have a very irregular flow of upgrading so it could be a good choice to have for them.

Or, installing the update- notifier, and six months later, what is that green thingy there? big_smile

Offline

#11 2023-03-19 01:57:49

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,560
Website

Re: A package update notifier?

orionH wrote:

Or, installing the update- notifier, and six months later, what is that green thingy there? big_smile

This is mostly still up in the air, but I imagine if there was an icon in the system tray it would have a tooltip saying something about itself. Also, my current image is of an icon that would only appear when there were upgrades.

The whole thing should aim to be light on RAM and CPU, certainly no more than other utilities we already use.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#12 2023-03-20 20:47:14

ceeslans
Member
Registered: 2015-09-30
Posts: 195

Re: A package update notifier?

sleekmason wrote:

The line works well.

Made a simple executor script to change a tint2 icon out based in part on brontos work above. Using a green colored icon for when updates are available. Looks like a bunch of ways to have the notification.  What fun.

#!/bin/bash

iconpath="$HOME/.config/tint2/executors/icons/update/"
status=$(apt list --upgradable | expr "$(wc -l)" - 1)

if [ "$status" != 0 ]; then
    echo "${iconpath}upgrade-yes.png"
else
    echo "${iconpath}upgrade-no.png"
fi 

Yes, it does work well - as long as there are no held packages (e.g. marked 'hold' to avoid upgrading to a higher version).

An easy solution would be to distract the number of 'held' packages from the number of 'upgradable' packages, but I fall short when trying to create the correct command...
Afaik, this is the command to determine the number of held packages:

apt-mark showhold | expr "$(wc -l)"

How could this be incorporated in the above script. Any help would be greatly appreciated
Thanks in advance!

Offline

#13 2023-03-21 04:16:09

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,560
Website

Re: A package update notifier?

ceeslans wrote:

...as long as there are no held packages (e.g. marked 'hold' to avoid upgrading to a higher version).

Good point!
Thanks for this reminder anyway.

---
This might work for the "status" line:

status=$(( $(apt list --upgradable 2>/dev/null | wc -l ) - $( apt-mark showhold | wc -l ) -1 ))

Though I was hoping to generate a list of the upgradeable packages, not just the total number, so the code will be a bit more complicated...

Last edited by johnraff (2023-03-21 04:40:40)


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#14 2023-03-21 13:30:15

sleekmason
zoom
Registered: 2018-05-22
Posts: 1,103
Website

Re: A package update notifier?

Oh good! Glad that came up, and yes, that works well.  I'll adjust the script above.

Offline

#15 2023-03-21 13:39:19

ceeslans
Member
Registered: 2015-09-30
Posts: 195

Re: A package update notifier?

johnraff wrote:

...
This might work for the "status" line:

status=$(( $(apt list --upgradable 2>/dev/null | wc -l ) - $( apt-mark showhold | wc -l ) -1 ))

@johnraff :  yep, that did the trick (for me anyway) . thanks for your help!

VUM3Hvut.png

Last edited by ceeslans (2023-03-21 13:41:04)

Offline

#16 2023-04-23 06:52:45

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,560
Website

Re: A package update notifier?

johnraff wrote:

I was hoping to generate a list of the upgradeable packages, not just the total number, so the code will be a bit more complicated...

I think listing the upgradeable package names, without the held packages, in a GUI will be too complicated. Just showing the number of packages is much easier.

Present thoughts (all this would go in an installable/removable package):

1) Set

APT::Periodic::Update-Package-Lists "1";

in /etc/apt/apt.conf.d/bunsen-updates
Apt will keep its databases automatically up to date, I think once a day by default, which sounds reasonable.

2) (possibly systemd) timer to run ~10min after bootup and every 24hrs after that, which runs a script to check the content of

possible_upgrades=$(( $(apt list --upgradable 2>/dev/null | wc -l ) - $( apt-mark showhold | wc -l ) -1 ))

That number is the upgradeable packages minus the held packages. If it's above zero, then...

3) Make a yad system tray icon, tooltip says "$possible_upgrades packages can be upgraded".

3a) Also put up a notify-send notification bubble (fades after ~15s).

If user chooses "check upgrades" from the icon menu, then do this:

x-terminal-emulator -T 'UPDATES' -e sh -c 'echo "Available upgrades:"; apt list --upgradeable; echo; echo "Held packages:"; apt-mark showhold; bash;'

If you run that command you'll see it displays the upgradeable packages, the held packages, then a bash prompt. User is then free to do whatever they like. No automatic upgrades.

A --reset command is then sent to the script which closes the icon, regardless of whether the user upgraded or not. If there are still upgradeable packages the icon will return 24hrs later.

Does that sound like a reasonable algorithm? I don't think it should be too hard to implement.

Have to look into exactly how yad systray icons behave - don't want to take up any amount of RAM for this. It might be easier to change the icon and tooltip rather than create and destroy it.

Also, that systemd timer - userland or system? Could be a bit tricky.

Last edited by johnraff (2023-04-23 07:07:52)


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#17 2023-04-23 07:44:34

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,560
Website

Re: A package update notifier?

^Or, PLAN B

Offer to install package-update-indicator in bl-welcome, and ship a config file that runs that same command:

x-terminal-emulator -T 'UPDATES' -e sh -c 'echo "Available upgrades:"; apt list --upgradeable; echo; echo "Held packages:"; apt-mark showhold; bash;'

when "Install updates" is clicked?

I've had this running on my system for a while now and it uses about as much RAM as pnmixer. Not negligable, but not enormous. Brings in a fair number of dependencies like packagekit though.
(Come to think of it, it was that which got me thinking of a roll-your -own solution.)

Dev team load would be greatly reduced of course... smile

Last edited by johnraff (2023-04-23 08:07:56)


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#18 2023-04-24 13:54:54

sleekmason
zoom
Registered: 2018-05-22
Posts: 1,103
Website

Re: A package update notifier?

Here is one possibility for a user activated notifier in a yad system tray notification with an upgradeable package count. 

If 0 updates, then exit. If greater than 0, place a yad notification in the system tray with right-click options to 'quit' or 'some-command-update-script'>.

One can keep the notification in the system tray indefinitely if desired, and continue to check for updates on occasion by left-clicking the yad notification for any currently available packages, or exit and just check on occasion. 

All that is needed is a menu/button/whatever to activate the notification.

#!/bin/bash
## Script to toggle apt notifier notification tray icon action on/off in tint2

num=$(( $( apt list --upgradable 2>/dev/null | wc -l ) - $( apt-mark showhold | wc -l ) -1 ))
notify-send  -t 15000 --urgency low "$num Update(s) Currently Available"

if [ "$num" != 0 ]; then
yad --notification --image="software-update-available" \
--text="Apt Notifier - Right-Click For Options" \
--menu="Apt Update!x-terminal-emulator -e 'sudo apt upgrade'!applications-other|Quit!quit!application-exit" \
--command="notify-send  -t 15000 --urgency low '$num Update(s) Currently Available'"
exit
fi

The --command line can also be shortened to --command="" to remove the left-click option, or, remove the line entirely to create a 'close on left click' command.

Easy enough to create a nice matching icon as well.

Lots of possibilities here.

Last edited by sleekmason (2023-04-24 14:07:49)

Offline

#19 2023-04-25 02:24:00

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,560
Website

Re: A package update notifier?

^thanks, that looks like a good place to start.

But I think for this to be a useful reminder it needs to be triggered by a timer. If the user had to remember to click an icon to check for upgrades, then they might as well just go ahead and do an apt update/upgrade in a terminal.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#20 2023-04-25 08:30:59

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,560
Website

Re: A package update notifier?

I edited @sleekmason's script a bit - when you click "Show Available Upgrades", instead of going straight to an apt upgrade it shows the upgradeable packages and the held packages, then drops to a bash prompt so the user can do whatever they want.

One thing I haven't figured out is how to close the icon once the terminal has done its work. I don't want to have to close it separately.

Also made a systemd timer to run the script 10 min after bootup and every day after that.

~/projects/update-notifyer/apt-update-check.sh # note spelling error

#!/bin/bash

num_upgrades=$(( $( apt list --upgradable 2>/dev/null | wc -l ) - $( apt-mark showhold | wc -l ) -1 ))

if (( num_upgrades == 0 )); then
    notify-send  -t 15000 --urgency low "$num_upgrades Upgrades(s) Currently Available"
    yad --notification --image="software-update-available" \
    --text="Package Upgrades - Right-Click For Options" \
    --menu="Show Available Upgrades!x-terminal-emulator -T 'Available Package Upgrades' -e sh -c 'printf \"%s\n\" \"Available upgrades:\"; apt list --upgradeable; printf \"\n%s\n\n\"  \"Held packages:\"; apt-mark showhold; bash;'!applications-other|Quit!quit!application-exit" \
    --command="notify-send  -t 15000 --urgency low '$num_upgrades Upgrades(s) Currently Available'"
fi

~/.config/systemd/user/apt-update-check.timer

[Unit]
Description=Run apt-update-check daily and on boot

[Timer]
OnBootSec=10min
OnUnitActiveSec=1day

[Install]
WantedBy=timers.target

~/.config/systemd/user/apt-update-check.service

[Unit]
Description=Check for available apt upgrades

[Service]
Type=oneshot
ExecStart=/home/john/projects/update-notifyer/apt-update-check.sh

And run:

systemctl --user enable apt-update-check.timer

Now to wait a few days and see if any updates come in...


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

Board footer

Powered by FluxBB