manatools / dnfdragora

dnfdragora is a dnf frontend based on libyui abstraction
GNU General Public License v3.0
137 stars 41 forks source link

Option to hide updater tray icon if non updates are available (Gnome 3 and lxqt) #167

Closed szpak closed 4 years ago

szpak commented 4 years ago

I use dnfdragora mostly to be aware that there are some updates available for my Fedora (I use dnf update from a console). As dnfdragora(-updater) displays a notification at system startup I don't need an icon visible in a system tray all the time. In general, it would not be a problem, however, I have also some other applets/extensions and one icon less matters in my case.

As a result I would like to propose one of the following options:

Btw, Gnome Shell doesn't support a system tray directly, but there are some extensions which emulate it.

anaselli commented 4 years ago

Which dnfdragora version are you using? in the 2.1.0 i added an experimental option, that unfortunately didn't work in any tests i made in various desktops to be set as default. Maybe you are lucky and works in your. Tell us if so...

immagine

szpak commented 4 years ago

Sorry, I forgot to mention that:

$ rpm -q dnfdragora
dnfdragora-2.0.4-2.fc32.noarch

There is currently no 2.1.0 build for Fedora, but I will try to manage it.

szpak commented 4 years ago

I built the new version and packaged it into rpm successfully, however, it fails at runtime (both dnfdragora and updater):

Traceback (most recent call last):
  File "/usr/bin/dnfdragora-updater", line 36, in <module>
    import dnfdragora.updater
  File "/usr/lib/python3.8/site-packages/dnfdragora/updater.py", line 16, in <module>
    from dnfdragora import config, misc, dialogs, ui, dnfd_client
  File "/usr/lib/python3.8/site-packages/dnfdragora/dialogs.py", line 21, in <module>
    import manatools.ui.basedialog as basedialog
ModuleNotFoundError: No module named 'manatools'

I wonder, if the problem could be the old libyui-mga available in Fedora:

$ rpm -qa | grep libyui-mga
libyui-mga-ncurses-1.0.2-0.20.git026f2e6.20131215.fc32.x86_64
libyui-mga-gtk-1.0.2-0.20.git22f2cf6.20131215.fc32.x86_64
libyui-mga-1.0.8-0.19.gita6a160e.20160313.fc32.x86_64
libyui-mga-qt-1.0.3-0.20.gitb508e88.20140119.fc32.x86_64

?

If yes, can I force using the old widgets even though the libraries are installed in the system?

szpak commented 4 years ago

Ok, it just can be caused by missing python-manatools - https://bugzilla.redhat.com/show_bug.cgi?id=1885034

Is it a new required dependency? It's not clear in the changelog for me.

anaselli commented 4 years ago

Is it a new required dependency? It's not clear in the changelog for me.

It is. The option dialog shown above is developed by using python-manatools, as it should be all the manatools (GUI) and dnfdragora as well, but dnfdragora is born before and change its main dialog requires time...

Requirements are into README where libyui-mga is required higher than the real requirement just because @Conan-Kudo needed to package it for older fedora so i added widget back compatibility later.

szpak commented 4 years ago

I have no luck with 2.1.0 on Fedora so far (could it be a general problem not only related to Fedora?), but just to verify, there should be no icon at start or it should hide once determined that there is no updates (e.g. there were installed using dnf in the meantime)?

anaselli commented 4 years ago

In my dreams it should start with dnfdragora icon, check for updates, hide icon if no updates or show the dnfdragora-updater one otherwise. But you could have fallen into issue #168, or as i experienced that didn't work, icon sometimes came up then disappeared even if there were updates, then after a second timed check appeared.... i maybe wrong in using pystray :/

szpak commented 4 years ago

Definitely it disappears instantaneously when I click "check for updates" in the context menu. Nevertheless, maybe the aforementioned error with notifications causes it:

> (dnfdragora-updater:26035): Gdk-CRITICAL **: 12:30:30.064: gdk_window_thaw_toplevel_updates: assertion 'window->update_and_descendants_freeze_count > 0' failed
> Exception in thread Thread-1:
> Traceback (most recent call last):
>   File "/usr/lib64/python3.8/threading.py", line 932, in _bootstrap_inner
>     self.run()
>   File "/usr/lib64/python3.8/threading.py", line 870, in run
>     self._target(*self._args, **self._kwargs)
>   File "/usr/lib/python3.8/site-packages/dnfdragora/updater.py", line 343, in __update_loop
>     self.__tray.notify(title='dnfdragora-update', message=_('%d updates available.') % self.__update_count)
>   File "/usr/lib/python3.8/site-packages/pystray/_base.py", line 234, in notify
>     self._notify(message, title)
>   File "/usr/lib/python3.8/site-packages/pystray/_util/gtk.py", line 81, in _notify
>     self._notifier.notify(title or self.title, message, self._icon_path)
>   File "/usr/lib/python3.8/site-packages/pystray/_util/notify_dbus.py", line 69, in notify
>     shutil.copy(icon, self._icon),
>   File "/usr/lib64/python3.8/shutil.py", line 415, in copy
>     copyfile(src, dst, follow_symlinks=follow_symlinks)
>   File "/usr/lib64/python3.8/shutil.py", line 261, in copyfile
>     with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
> FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpd9ew4mco'
> Try reading configuration file
> From ./dnfdragora.yaml
> Skipped exception: <[Errno 2] No such file or directory: './dnfdragora.yaml'> 
> From /etc/dnfdragora/dnfdragora.yaml
> Finally read user settings from /home/foobar/.config/dnfdragora.yaml
> Logging disabled
> <_M_> [ui] YUILoader.cc:50 loadUI(): DISPLAY: ":0"

I will try to retest it, once it is fixed in Fedora.

szpak commented 4 years ago

Hmm, once the icon disappeared after a minute after dnfdragora-updater start when there were no updates, nice :-).

2020-10-09 18:20:30,273 [dnfdragora.updater]{updater.py:217}(INFO) Scheduled check for updates in 1 minutes
2020-10-09 18:21:30,347 [dnfdragora.updater]{updater.py:282}(DEBUG) Start getting updates
2020-10-09 18:21:30,347 [dnfdaemon.client]{dnfd_client.py:362}(DEBUG) run_dbus_async Lock
2020-10-09 18:21:30,347 [dnfdaemon.client]{dnfd_client.py:340}(DEBUG) __async_thread_loop Command Lock() requested 
2020-10-09 18:21:30,539 [dnfdaemon.client]{dnfd_client.py:270}(DEBUG) return_handler Lock
2020-10-09 18:21:30,539 [dnfdaemon.client]{dnfd_client.py:292}(DEBUG) get_result Lock
2020-10-09 18:21:30,539 [dnfdaemon.client]{dnfd_client.py:283}(DEBUG) Quit return_handler error None
2020-10-09 18:21:30,848 [dnfdragora.updater]{updater.py:316}(INFO) Event received Lock - info {'result': True, 'error': None}
2020-10-09 18:21:30,848 [dnfdaemon.client]{dnfd_client.py:362}(DEBUG) run_dbus_async GetPackages
2020-10-09 18:21:30,849 [dnfdaemon.client]{dnfd_client.py:340}(DEBUG) __async_thread_loop Command GetPackages(('(sas)', 'updates_all', [])) requested 
2020-10-09 18:21:30,849 [dnfdragora.updater]{updater.py:320}(DEBUG) Getting update packages
2020-10-09 18:21:30,849 [dnfdragora.updater]{updater.py:380}(INFO) Scheduled check for updates in 180 minutes
2020-10-09 18:21:33,214 [dnfdaemon.client]{dnfd_client.py:270}(DEBUG) return_handler GetPackages
2020-10-09 18:21:33,214 [dnfdaemon.client]{dnfd_client.py:292}(DEBUG) get_result GetPackages
2020-10-09 18:21:33,214 [dnfdaemon.client]{dnfd_client.py:283}(DEBUG) Quit return_handler error None
2020-10-09 18:21:33,352 [dnfdragora.updater]{updater.py:329}(DEBUG) Got GetPackages event menu visibility is True
2020-10-09 18:21:33,353 [dnfdragora.updater]{updater.py:334}(DEBUG) Event received GetPackages
2020-10-09 18:21:33,353 [dnfdragora.updater]{updater.py:338}(INFO) Found 0 updates
2020-10-09 18:21:33,353 [dnfdragora.updater]{updater.py:354}(DEBUG) No updates found
2020-10-09 18:21:33,353 [dnfdragora.updater]{updater.py:356}(DEBUG) Menu visibility is False
2020-10-09 18:21:33,356 [dnfdragora.updater]{updater.py:365}(DEBUG) RPM DB unlocked
2020-10-09 18:21:33,356 [dnfdragora.updater]{updater.py:207}(DEBUG) rescheduling
2020-10-09 18:21:33,356 [dnfdragora.updater]{updater.py:209}(DEBUG) Reset scheduler
2020-10-09 18:21:33,356 [dnfdragora.updater]{updater.py:217}(INFO) Scheduled check for updates in 180 minutes

Menu visibility is False

I have to play longer with it to verify it works regularly and if it can detect new updates.

However, quite often, when I start dnfdragora-updater manually I observe:

2020-10-09 18:12:25,699 [dnfdragora.updater]{updater.py:217}(INFO) Scheduled check for updates in 1 minutes
2020-10-09 18:13:25,773 [dnfdragora.updater]{updater.py:282}(DEBUG) Start getting updates
2020-10-09 18:13:25,773 [dnfdaemon.client]{dnfd_client.py:362}(DEBUG) run_dbus_async Lock
2020-10-09 18:13:25,774 [dnfdaemon.client]{dnfd_client.py:340}(DEBUG) __async_thread_loop Command Lock() requested 
2020-10-09 18:13:25,774 [dnfdaemon.client]{dnfd_client.py:270}(DEBUG) return_handler Lock
2020-10-09 18:13:25,774 [dnfdaemon.client]{dnfd_client.py:292}(DEBUG) get_result Lock
2020-10-09 18:13:25,775 [dnfdaemon.client]{dnfd_client.py:283}(DEBUG) Quit return_handler error None
2020-10-09 18:13:26,274 [dnfdragora.updater]{updater.py:316}(INFO) Event received Lock - info {'result': False, 'error': None}
2020-10-09 18:13:26,274 [dnfdragora.updater]{updater.py:207}(DEBUG) rescheduling
2020-10-09 18:13:26,274 [dnfdragora.updater]{updater.py:217}(INFO) Scheduled check for updates in 1 minutes
2020-10-09 18:14:26,340 [dnfdragora.updater]{updater.py:282}(DEBUG) Start getting updates
2020-10-09 18:14:26,341 [dnfdaemon.client]{dnfd_client.py:362}(DEBUG) run_dbus_async Lock
2020-10-09 18:14:26,341 [dnfdaemon.client]{dnfd_client.py:340}(DEBUG) __async_thread_loop Command Lock() requested 
2020-10-09 18:14:26,342 [dnfdaemon.client]{dnfd_client.py:270}(DEBUG) return_handler Lock
2020-10-09 18:14:26,342 [dnfdaemon.client]{dnfd_client.py:292}(DEBUG) get_result Lock
2020-10-09 18:14:26,343 [dnfdaemon.client]{dnfd_client.py:283}(DEBUG) Quit return_handler error None
2020-10-09 18:14:26,842 [dnfdragora.updater]{updater.py:316}(INFO) Event received Lock - info {'result': False, 'error': None}
2020-10-09 18:14:26,842 [dnfdragora.updater]{updater.py:207}(DEBUG) rescheduling
2020-10-09 18:14:26,842 [dnfdragora.updater]{updater.py:217}(INFO) Scheduled check for updates in 1 minutes

Why it was rescheduled (it could get a lock?)? I don't have any dnf session running in the background. ps aux | grep dnf returns:

/usr/bin/python3 /usr/share/dnfdaemon/dnfdaemon-system

Could it be a reason?

anaselli commented 4 years ago

iirc rescheduling is a choice i made to check for updates if

  1. DB is locked and cannot be taken
  2. User runs dnfdraogora or update menu and after that we need to check for packages again to be sure that there are no more updates.

I seem i can't see the _run_dbusasync GetPackages line so something seems to be wrong. I need to do more tests, but remember that at the moment this feature is still experimental

anaselli commented 4 years ago

hmm if dnfdragora is open then it could be normal. I missed this line:

2020-10-09 18:14:26,842 [dnfdragora.updater]{updater.py:316}(INFO) Event received Lock - info {'result': False, 'error': None}

Lock is false so, dnfdragora is trying to get the lock to check for updates and test it every minutes until it can get it.

If dnfdragare were exited badly that is another reason why you could get this behaviour. You could see it if dnfdragora is not running and maybe a crash has been experienced before a way to go on is to run on a terminal without closing dnfdragora-updater

dnfdragora --exit

anaselli commented 4 years ago

FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpd9ew4mco'

It seems related to issue #170 as well here

szpak commented 4 years ago

I switched the updates check interval to 5 minutes and I was able to go through the both cases - an icon is hidden when no updates are available and is restored if there are new updates. In the end, it seems to work as expected, at least with Gnome 3 :). Closing.

Btw, one more (possibly) related glitch. When I click "Check for updates" from the context menu, the icon disappears for a few seconds.

In the debug log I see then:

2020-10-09 22:15:45,973 [dnfdragora.updater]{updater.py:269}(DEBUG) Start checking for updates, by menu command
2020-10-09 22:15:45,974 [dnfdaemon.client]{dnfd_client.py:362}(DEBUG) run_dbus_async Lock
2020-10-09 22:15:45,974 [dnfdaemon.client]{dnfd_client.py:340}(DEBUG) __async_thread_loop Command Lock() requested 
2020-10-09 22:15:46,095 [dnfdaemon.client]{dnfd_client.py:270}(DEBUG) return_handler Lock
2020-10-09 22:15:46,095 [dnfdaemon.client]{dnfd_client.py:292}(DEBUG) get_result Lock
2020-10-09 22:15:46,095 [dnfdaemon.client]{dnfd_client.py:283}(DEBUG) Quit return_handler error None
2020-10-09 22:15:46,532 [dnfdragora.updater]{updater.py:316}(INFO) Event received Lock - info {'result': True, 'error': None}
2020-10-09 22:15:46,532 [dnfdaemon.client]{dnfd_client.py:362}(DEBUG) run_dbus_async GetPackages
2020-10-09 22:15:46,533 [dnfdaemon.client]{dnfd_client.py:340}(DEBUG) __async_thread_loop Command GetPackages(('(sas)', 'updates_all', [])) requested 
2020-10-09 22:15:46,533 [dnfdragora.updater]{updater.py:320}(DEBUG) Getting update packages
2020-10-09 22:15:48,083 [dnfdaemon.client]{dnfd_client.py:270}(DEBUG) return_handler GetPackages
2020-10-09 22:15:48,083 [dnfdaemon.client]{dnfd_client.py:292}(DEBUG) get_result GetPackages
2020-10-09 22:15:48,083 [dnfdaemon.client]{dnfd_client.py:283}(DEBUG) Quit return_handler error None
2020-10-09 22:15:48,536 [dnfdragora.updater]{updater.py:329}(DEBUG) Got GetPackages event menu visibility is False
2020-10-09 22:15:48,536 [dnfdragora.updater]{updater.py:334}(DEBUG) Event received GetPackages
2020-10-09 22:15:48,536 [dnfdragora.updater]{updater.py:338}(INFO) Found 1 updates
2020-10-09 22:15:48,536 [dnfdragora.updater]{updater.py:356}(DEBUG) Menu visibility is True
2020-10-09 22:15:48,537 [dnfdragora.updater]{updater.py:365}(DEBUG) RPM DB unlocked
2020-10-09 22:15:48,537 [dnfdragora.updater]{updater.py:207}(DEBUG) rescheduling
2020-10-09 22:15:48,537 [dnfdragora.updater]{updater.py:209}(DEBUG) Reset scheduler
2020-10-09 22:15:48,537 [dnfdragora.updater]{updater.py:217}(INFO) Scheduled check for updates in 5 minutes

However, it might be done on purpose - e.g. to do confuse users to try to click it the seconds time, while they updates are being processed.

Regarding:

FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpd9ew4mco' It seems related to issue #170 as well here

Yes, it was exactly the same problem. python3-pystray-0.17.1 fixed that (I just extracted it to a separate issue in the meantime to do not loose it in that one).