Package: seafile-nautilus
Descriptionseafile_nautilusprovides gnome-files (Nautilus) users the ability to manage seafile
links directly from the file manager (right-click menu > scripts). Once the package is
installed, theseafile-nautiluscommand is defined for the user and can be called
in a Nautilus script (note the dash-instead of the underscore_).Seafile_nautilus relies on its own seafile API which, unlike many others,does not ask
the user for the server address, login and password. Instead, it retrieves the
seafile client parameters and token (stored locally in the user's personal folder)
to authenticate. Of course, this requires that the seafile client is installed
and properly configured.seafile_nautilusmainly focuses on seafile links:share link,internal linkandupload link(for folders). Multiple actions that can be performed on local files contained
in synchronized libraries:display link url,display link properties (creator name, expiration date, number of views, password, etc.),create links,delete links,alter link permissions: on cloud edition, download, upload.seafile_nautilusalso allows to open directly a file or a folder in the cloud.Graphical user interfaceThe dialogs are based onzenity. Be sure you havezenitycorrectly installed.How to install0. PrerequisitesIf not already present, installpip3andzenity:$ sudo apt install python3-pip
$ sudo apt install zenity1. Installseafile_nautiluspackage:$ pip3 install seafile_nautilusIfpipraises the warning belowWARNING: The script seafile-nautilus is installed in '/home/USER/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.simply log out and in again.Now, if the previous operations were successful, typeseafile-nautilusin a terminal
and you should get the response below:$ seafile-nautilus
This is seafile_nautilus version x.y.z

usage: seafile-nautilus [-h] [-v] file [file ...]
seafile-nautilus: error: the following arguments are required: file2. Create a nautilus interface$ cd ~/.local/share/nautilus/scripts/
$ echo '#!/usr/bin/sh'    >  seafile_nautilus
$ echo 'seafile-nautilus' >> seafile_nautilus
$ chmod +x seafile_nautilusTip: If the first command fails for the folder does not exist, then type$ mkdir -p ~/.local/share/nautilus/scripts/3. Optionnal: setseafile_nautilusicon to the script:$ gio set seafile_nautilus metadata::custom-icon 'file://'$(python3 -m site --user-site)'/seafile_nautilus/icons/icon.png'Usage1. from NautilusSimply right-click on a file or folder from a synchronized
library, choosescriptsthenseafile_nautilus.2. from a terminal$ seafile-nautilus relative/or/absolute/path/to/the/file/or/folder3. from python: simple usage>>> from seafile_nautilus.main import main
>>> main('relative/or/absolute/path/to/the/file/or/folder')4. from python: api usageInstead of callingseafile_nautilus.mainfunction you can use directly the
seafile api by importing classes fromseafile_nautilus.seafile.>>> from seafile_nautilus.seafile import *
>>> from pprint import pprintCreate aSeafileAccount(). This requires thatseafile-cliis installed and correctly
configured (server, user, password).>>> account = SeafileAccount()
>>> account.username
'john.doe@xyz.com'

>>> account.url
'https://seafile.server.com'
 
>>> account.token
'c9fdd29e372ed61deb1540a6b066a7ce6c53b44f'One can list the libraries stored on the safile server:>>> account.remote_repository.get_libs()
{<RemoteLibrary> id=5092085d-11bb-4f52-aa7e-7ac49c6287d4 name=Folder1,
 <RemoteLibrary> id=d9a74e89-348b-4ae3-953a-72eb0835be54 name=Folder2,
 <RemoteLibrary> id=8affbb97-50d0-4998-975c-a5ccff650c31 name=Folder3,
 <RemoteLibrary> id=8ac50c31-ac49-74e8-085d-2eb08affbc87 name=Folder4}And those stored and synchronized locally:>>> account.local_repository.local_libraries
{<LocalLibrary> id=5092085d-11bb-4f52-aa7e-7ac49c6287d4 name=/home/john/Seafile/Folder1,
 <LocalLibrary> id=d9a74e89-348b-4ae3-953a-72eb0835be54 name=/home/john/Seafile/Folder2,
 <LocalLibrary> id=8affbb97-50d0-4998-975c-a5ccff650c31 name=/home/john/Seafile/Folder3}Choose one element (file or folder) of a synchronized library>>> elt = SyncedElement(account, '/home/john/Seafile/Folder1/my_file.pdf')Look at the file details from the seafile server point of view:>>> pprint(elt.file_details.__dict__)  # for folders, use 'elt.dir.details' instead
{'can_edit': False,
 'comment_total': 0,
 'id': '92ab1f0bfa3549100425279833701024adf04f11',
 'last_modified': datetime.datetime(2021, 11, 22, 7, 43, 48, tzinfo=datetime.timezone(datetime.timedelta(seconds=3600))),
 'last_modifier_contact_email': 'john.doe@xyz.com',
 'last_modifier_email': 'john.doe@xyz.com',
 'last_modifier_name': 'John DOE',
 'mtime': 1637563428,
 'name': 'my_file.pdf',
 'permission': 'rw',
 'size': 146945,
 'starred': False,
 'type': 'file'}Check whether the file already has a share link:>>> details = elt.get_share_link_details()
>>> details.link
'https://seafile.server.com/d/8aa5fe4897375a988712/'If yes, you can display its permissions:>>> details.permissions
Permissions(can_edit=False, can_download=True, can_upload=False)You can set different permission parameters  (disallowing download for example):>>> new_perm = Permissions(can_edit=False, can_download=False, can_upload=False)
>>> elt.set_share_link_permissions(new_perm)
>>> elt.get_share_link_details().permissions
Permissions(can_edit=False, can_download=False, can_upload=True)Let's see the file on the cloud:>>> elt.show_on_cloud()TroubleshootingWhen things go wrong (or simply do not go at all!) usingseafile_nautilusas a
nautilus script , you can get exception traceback by launching nautilus from
terminal with a different temporary directory:$ nautilus -q && mkdir /tmp/nautilus-testing; TMPDIR=/tmp/nautilus-testing nautilus --no-desktop