nextcloud / desktop

💻 Desktop sync client for Nextcloud
https://nextcloud.com/install/#install-clients
GNU General Public License v2.0
2.91k stars 773 forks source link

Shell integration for Thunar (XFCE) #6453

Open yab5 opened 5 months ago

yab5 commented 5 months ago

Hi everyone,

similar to desktop integration plugins [1] for other DEs on Linux, like Gnome and KDE, I'd like to request a similar plugin for the XFCE Desktop and its file manager Thunar.

So, having

SamMousa commented 3 months ago

I just found this issue and was thinking of a more generic away to solve it without requiring communication with the desktop client. Currently the thunar plugin connect to nextcloud via a socket to get the status of files, which is error prone and probably relatively intense with respect to resource usage.

What about storing this state in extended file attributes? That way the client can just write the information in a standard way and the integration(s) for each file manager just need to read them.

alexxcons commented 1 month ago

Sure, it would be possible to have nextcloud specific info in the file xattr (or in the gvfs file metadata) ... though not sure from where thunar should obtain that info in the first place.

It seems like there is a libnextcloudsync available in distro repos ... I suppose it provides an API for that ?

There seems to be an integration for e.g. caja, though not sure where the sources for it are located ... I suppose thunar could just do the same.

Edit: Ok, found the nautilus/caja integration, seems to as well use socket connect via some python script: https://github.com/nextcloud/desktop/blob/5e9c7dbb57c96663f81d42dd09ead16bbc5163c2/shell_integration/nautilus/syncstate.py#L95

As well all other clients below desktop/shell_integration seem to use sockets to communicate with nextcloud-desktop

SamMousa commented 1 month ago

though not sure from where thunar should obtain that info in the first place.

The idea would be that nextcloud makes a specification for extended attributes that they use. Then a Thunar plugin (or any other file manager plugin) would read the extended file attributes.

For example the thunar-media-tags-plugin reads the file using taglib. (This is for audio tags which live inside file content, so that's different)

If you look at the source code for the audio tags page from that plugin: https://gitlab.xfce.org/thunar-plugins/thunar-media-tags-plugin/-/blob/master/thunar-plugin/audio-tags-page.c?ref_type=heads#L86

You'll see that it essentially uses a reference to the file of type ThunarxFileInfo. https://developer.xfce.org/thunarx/ThunarxFileInfo.html The function thunarx_file_info_get_file_info returns a GFileInfo.

I'm not fluent in C but am confident based on this research that it should be possible and relatively easy as well.

alexxcons commented 1 month ago

A problem with that approach might be to notice changes on files using X-Attributes. Afaik e.g. the Gio FileMonitor does not trigger thunar when file metadata is changed.

E.g. you can set an emblem via CLI: gio set my_file metadata::emblems --type=stringv emblem-debian emblem-default, though thunar will only reload the file and as such show the new emblem if you press F5 (refresh).

As well, I dont know if meanwhile all filesystems/OSes do support xattr.

Imo a more straight approach would be to communicate via some library, e.g. libnextcloudsync if that offers an API to do so.

However, socket communication seems to work fine so far ... so as long as there is no concrete problem with it, I don't see a strong need to move to something else.