Skip to content
This repository has been archived by the owner on Oct 3, 2020. It is now read-only.

Run programs to update desktop integration #50

Merged
merged 5 commits into from
Dec 3, 2018
Merged

Run programs to update desktop integration #50

merged 5 commits into from
Dec 3, 2018

Conversation

rszibele
Copy link
Contributor

@rszibele rszibele commented Dec 2, 2018

This PR fixes issue #34.

Implementation

It checks if the following programs are available in the users $PATH:

  • update-desktop-database
  • update-mime-database
  • gtk-update-icon-cache
  • kbuildsycoca5

Based on the availability of each program, it executes each of them within a thread if more than 3 seconds have passed since the last AppImage was added. If another AppImage is dropped into one of the watched directories while still within the 3 seconds, then the timer is reset. So if suddenly a user drops 20 AppImages into the directory, the update will only be executed once.

Note: The execution time of the desktop update depends on the system, but it generally falls in the 100-600ms range, according to my tests on my main machine and an older laptop.

Tests

I have manually tested this with the Libreoffice and Subsurface AppImages on the following distributions:

  • Kubuntu 18.10 (KDE)
  • Ubuntu 18.10 (Gnome)
  • Xubuntu 18.10 (XFCE)
  • Linux Mint 19 (Cinnamon)
  • Linux Mint 19 (MATE)
  • Elementary 5 (Elementary)

@probonopd
Copy link
Member

probonopd commented Dec 2, 2018

Hello @rszibele, welcome to AppImage. Great to have you here. What an awesome PR for a first contribution. 👍

@probonopd
Copy link
Member

I think the following is caused by https://github.com/linuxdeploy/linuxdeploy-plugin-appimage, @TheAssassin please have a look:

[appimage/stderr] Embedding MD5 digest
[appimage/stderr] gpg2 and sha256sum are installed and user requested to sign, hence signing
[appimage/stderr] /usr/bin/sha256sum appimaged-x86_64.AppImage
[appimage/stderr] /usr/bin/gpg2 --batch --detach-sign --armor   appimaged-x86_64.AppImage.digest
[appimage/stderr] gpg: no default secret key: No secret key
[appimage/stderr] gpg: signing failed: No secret key
[appimage/stderr] ERROR: gpg2 command did not succeed, could not sign, continuing

The signing should not be attempted for PRs, as PRs cannot access the key.

@probonopd
Copy link
Member

If I understand it correctly, then this PR runs the programs 5 seconds after the last activity. While this is clearly a step in the right direction, I think (might be wrong though) that merely copying in desktop files can trigger the running of such programs automatically. So we should also apply the same logic to copying around the files (desktop files, icon files, mime type files and such) that are needed for system integration.

Does this make sense @rszibele? Do you think you could have a go at it?

@rszibele
Copy link
Contributor Author

rszibele commented Dec 2, 2018

Hi, yes that makes sense I'll have a look at it.

@rszibele
Copy link
Contributor Author

rszibele commented Dec 2, 2018

Yes, you are correct. GNOME does this for each file, but from what I can tell they do not "rebuild" everything once a new .desktop file is added. KDE on the other hand doesn't do this, you have to manually call kbuildsycoca5.

I will have to look further into this issue, but I believe the slowdowns are primarily caused by integrating AppImages that are already integrated. Every time appimaged is started (e.g after logging in), it re-registers all AppImages by calling appimage_register_in_system which extracts the AppImage, does some manipulation, and copies the desktop file and icons to the correct location.

I'll add a check to ensure only those AppImages get integrated that aren't integrated already.

EDIT: appimaged also launches 1 pthread per file, this is very bad when you have, for example, extracted the linux kernel in your downloads folder. I'll think of a solution for this.

@probonopd
Copy link
Member

probonopd commented Dec 2, 2018

Thanks @rszibele for addressing this; I am sure it will make a big difference!
Feel free to also join the growing crowd at #appimage on irc.freenode.net, we'd be happy to welcome you there.

@probonopd
Copy link
Member

probonopd commented Dec 7, 2018

Actually it looks like I was a bit too fast merging this. It should rather be implemented in libappimage because

So please have a look at AppImageCommunity/libappimage#27 and AppImageCommunity/libappimage#28.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants