How does Zotero choose the file manager?

edited December 19, 2022
I have my xdg-open set up to open folders with a specific file manager.

However, when I right click on a item and select "Show File", Zotero opens the folder with another file manager.

It uses nautilus to open the folder, and I would like to know who told him to do that.

How is the file manager chosen?

I want to use my own.

I think Zotero should ask xdg-open to open the folder.

He knows the right file manager to use.
  • edited December 20, 2022
    The relevant code is here:

    https://github.com/zotero/zotero/blob/da392518ed22ead04c1c7cb617fee9bfdba87ec3/chrome/content/zotero/zoteroPane.js#L4668-L4677

    https://github.com/zotero/zotero/blob/da392518ed22ead04c1c7cb617fee9bfdba87ec3/chrome/content/zotero/xpcom/zotero.js#L954-L993

    https://github.com/zotero/zotero/blob/da392518ed22ead04c1c7cb617fee9bfdba87ec3/defaults/preferences/zotero.js#L194

    Zotero tries to use the Mozilla platform's file.reveal() method. If that isn't available (as on Linux), it tries to launch the parent directory via the OS, and if that fails it falls back to xdg-open. But this all depends entirely on your system.

    You can view the debug output view Tools → Developer → View Output to see exactly what it's doing for you.
  • I have Arch Linux.

    So it's not mozilla file.reveal() as it is not available on linux.

    What does it mean "launch the parent directory via the OS"?

    And what does this `file.launch()` (https://github.com/zotero/zotero/blob/da392518ed22ead04c1c7cb617fee9bfdba87ec3/chrome/content/zotero/xpcom/zotero.js#L961) do? Where does it come from?

    I have `extensions.zotero.fallbackLauncher.unix` set to the default `/usr/bin/xdg-open`, which in turn knows how to open the folder.

    Under linux you call xdg-open directly, without Mozilla's file.reveal() or that file.launch() that I don't know what it does.



  • We can't help with this — it's entirely dependent on your system. Again, you can view the debug output to see what it's doing. This just works on macOS and Windows, but there's no unified method of file revealing/launching on Linux, so you'd have to dig into your system settings to see what's specifying Nautilus. You can see a similar discussion for PDFs here:

    https://www.zotero.org/support/kb/file_handling_issues#pdfs_opening_in_wrong_application_on_linux_systems
  • Sorry, this is the debug output.

    It only says "Notifier.trigger('open', 'file', [3520])".

    What I'm supposed to do with this?

    > there's no unified method of file revealing/launching on Linux

    Just calling `xdg-open` would work on most systems.

    > you'd have to dig into your system settings to see what's specifying Nautilus

    Zotero is calling something that opens the directory.

    My system is not opening the folder on its own.

    So what system function is Zotero calling?

    What is this `file.launch()`?



    ```
    (3)(+12712849): Zotero.Items.keepParents() is deprecated -- use Zotero.Items.keepTopLevel() instead

    (4)(+0000004): SELECT IA.itemID FROM itemAttachments IA NATURAL JOIN items I LEFT JOIN itemData ID ON (IA.itemID=ID.itemID AND fieldID=13) LEFT JOIN itemDataValues IDV ON (ID.valueID=IDV.valueID) WHERE parentItemID=? AND linkMode NOT IN (3) AND IA.itemID NOT IN (SELECT itemID FROM deletedItems) ORDER BY contentType='application/pdf' DESC, value=? DESC, dateAdded ASC [3521, '']

    (4)(+0000016): SELECT IA.itemID FROM itemAttachments IA NATURAL JOIN items I LEFT JOIN itemData ID ON (IA.itemID=ID.itemID AND fieldID=13) LEFT JOIN itemDataValues IDV ON (ID.valueID=IDV.valueID) WHERE parentItemID=? AND linkMode NOT IN (3) AND IA.itemID NOT IN (SELECT itemID FROM deletedItems) ORDER BY contentType='application/pdf' DESC, value=? DESC, dateAdded ASC [3521, '']

    (4)(+0000003): SELECT IA.itemID FROM itemAttachments IA NATURAL JOIN items I LEFT JOIN itemData ID ON (IA.itemID=ID.itemID AND fieldID=13) LEFT JOIN itemDataValues IDV ON (ID.valueID=IDV.valueID) WHERE parentItemID=? AND linkMode NOT IN (3) AND IA.itemID NOT IN (SELECT itemID FROM deletedItems) ORDER BY contentType='application/pdf' DESC, value=? DESC, dateAdded ASC [3521, '']

    (4)(+0000003): SELECT IA.itemID FROM itemAttachments IA NATURAL JOIN items I LEFT JOIN itemData ID ON (IA.itemID=ID.itemID AND fieldID=13) LEFT JOIN itemDataValues IDV ON (ID.valueID=IDV.valueID) WHERE parentItemID=? AND linkMode NOT IN (3) AND IA.itemID NOT IN (SELECT itemID FROM deletedItems) ORDER BY contentType='application/pdf' DESC, value=? DESC, dateAdded ASC [3521, '']

    (3)(+0000003): MIME type application/pdf cannot be handled internally

    (4)(+0000001): SELECT IA.itemID FROM itemAttachments IA NATURAL JOIN items I LEFT JOIN itemData ID ON (IA.itemID=ID.itemID AND fieldID=13) LEFT JOIN itemDataValues IDV ON (ID.valueID=IDV.valueID) WHERE parentItemID=? AND linkMode NOT IN (3) AND IA.itemID NOT IN (SELECT itemID FROM deletedItems) ORDER BY contentType='application/pdf' DESC, value=? DESC, dateAdded ASC [3521, '']

    (4)(+0001360): SELECT IA.itemID FROM itemAttachments IA NATURAL JOIN items I LEFT JOIN itemData ID ON (IA.itemID=ID.itemID AND fieldID=13) LEFT JOIN itemDataValues IDV ON (ID.valueID=IDV.valueID) WHERE parentItemID=? AND linkMode NOT IN (3) AND IA.itemID NOT IN (SELECT itemID FROM deletedItems) ORDER BY contentType='application/pdf' DESC, value=? DESC, dateAdded ASC [3521, '']

    (3)(+0000002): Revealing /home/[ABRIDGED]/Zotero/storage/VA8CWAWX/Grennan et al. - GIANT The 1-Billion Annotated Synthetic Bibliogra.pdf

    (3)(+0000444): Notifier.trigger('open', 'file', [3520]) called [observers: 4]

    (3)(+0000341): itemTree.render(). Displaying Item Tree

    (3)(+0000357): itemTree.render(). Displaying Item Tree

    (3)(+0001507): itemTree.render(). Displaying Item Tree
    ```
  • edited December 20, 2022
    launch() is a Mozilla function. Zotero doesn't specify Nautilus or any other program, so it's by definition something on your system. You'll have to figure out where in your system settings that's specified. I linked above to an example of doing that for PDFs. I can't help you further with this.
  • This is actually an old Firefox bug/issue, by default it doesn't use the system's file picker. If you go to Zotero's Advanced settings about:config and add a setting widget.use-xdg-desktop-portal: true, Zotero will use your XDG setting (you also need to have e.g. xdg-desktop-portal-kde installed).
  • @Arjan I added the setting you mentioned and confirmed xdg-desktop-portal-gtk and xdg-desktop-portal-kde are installed, but Zotero still opens the wrong file manager for me. I set my default file manager to Caja on a Debian Linux machine and Zotero always opens Thunar file manager.
  • edited May 21, 2024
    If you, like me, never use Thunar, and have sudo rights, my heavy workaround is to just link the thunar bin to my preferred filemanager spacefm: ’sudo ln -sfvb /usr/bin/spacefm /usr/bin/thunar’
    Little drawback: In thunar the file already gets selected, in spacefm not, just the folder is opened.

    By the way: Thunar call must be quite special, tried 1st to replace it with a script showing the parameters given to it (to maybe do sth. like ’spacefm -s set selected_filenames ’), but that script did not even start, instead spacefm got opened. So don't blame me, if things will start to work unexpected ;-)
  • I've installed Zotero via Flathub and 'Show File' opens a terminal app. Not even the default terminal app. It used to work with the tarball installation but I hah other issues.

    Is there no way around this?
  • @Gabriel_p: We have nothing to do with the Flatpak. We can only help with the tarball and the zotero-deb package.
  • edited June 19, 2024
    The non-flatpack installs (bot tarball and zotero-deb) have this issue

    https://forums.zotero.org/discussion/109431/selected-row-folder-is-not-shown

    I just updated with a comment, could you check it out please?
Sign In or Register to comment.