Basically what the title says, I use Discover mainly as something that yells at me when I need to update, so when the “Updates available” notification pops up, it would be nice to have a button to open up the terminal on the pop up itself, even better if it let you customize it to open up a terminal and instantly run a command you put in (typically sudo apt-get update)
That implementation seems very subjective - it doesn’t seem generally useful, on one hand - on the other hand - it doesn’t sound like you are actually interested in discover at all - I mean it’s had a lot of functionality that you are completely disinterested in, you just want something that runs
pkcon get-updates periodically and if there’s something returned - show a notification and offer to run a command for you. That seems trivial to script.
I have something similar using the “run command” widget: it runs some script every few seconds, and shows the result in the widget - if the widget shows something specific, I will click it, and the widget is configured to launch an application with specific arguments.
It should be pretty straightforward to do something similar that uses
yad --notification --command="konsole --profile run-pkcon-upgrade" --text "you have updates" and create a konsole profile named “run-pkcon-upgrade” that just runs `pkcon upgrade" (or whatever command you want to use to run the system update).
I’ve looked into this a bit more, but I can’t find a way to show a system tray icon just with a shell (there are various relatively small programs that you can write, from Python to Go, but I decided not to mess with that).
My current fallback is using
notify-send to show a persistent notification with a button you can click on to launch the update. You can do various things with cron but I decided the correct way to do it is with systemd (not the least because otherwise it is harder to get to the desktop), so you need 3 files that look like this:
#!/bin/bash case $(notify-send \ --app-name 'Updates' --action update="Update" --urgency critical \ --icon system-software-update --hint string:desktop-entry:discover \ 'System updates are available' 'Click "Update" to launch the updater') in update) konsole -e /bin/bash -c 'pkcon update; read -p "Update done...";';; esac
[Unit] Description=Notify of system updates [Service] Type=oneshot ExecCondition=/usr/bin/pkcon get-updates ExecStart=%h/.local/bin/notify-updates.sh
[Unit] Description=Notify on system updates [Timer] OnCalendar=*:0/15 Persistent=true [Install] WantedBy=timers.target
Then to activate it run
systemctl --user enable --now notify-updates.timer. This will then run - as long as you are logged in to the desktop - a timer on every quarter hour that will activate a service. The service will first run
pkcon get-updates, and if that returns 0 (it will return 5 if there are no updates) then it will start the script that will show the notification and launch konsole for you.
I resorted to following plasmoid in lack of an independent newmail indicator without having to use kmail/akonadi.
I think it could make a nice update checker as well and should even work on systems (such as Devuan or FreeBSD) without relying on systemd.
Personally I wouldn’t go for yad but for kdialog or notify-send. ymmv.
I prefer kdialog as well, unfortunately it doesn’t support showing an app indicator. I understood from yad’s documentation (and tutorials) that it does - but that didn’t appear to be the case - so I used notify-send.
thumbs up same here. I think notify-send is a good solution.
I’ve replaced the existing update notifier with a custom one using the plasma widget Scriptinator with several shell scripts.
Basically, as a result: (1) my custom update notifier updates mirrors, and checks software updates periodically, showing the update icon in systray when necessary, with three different color dots depending on the number of packages to be updated.
(2) Clicking the update icon shows the list of upgradable packages, with several action buttons at the bottom, offering you to use either the terminal, the package manager or Discover to perform the pending update(s).