filetags icon indicating copy to clipboard operation
filetags copied to clipboard

[Help] Integration with gnome file manager Nautilus

Open bambirombi opened this issue 2 years ago • 6 comments

I have found this thanks to your amazing blog. I would like to know how to integrate it with nautilus file manager https://wiki.gnome.org/action/show/Apps/Files. Is there an easy way? I am not tech savvy so I have no idea how integrate with it to obtain similar results as your demonstration with windows.

Thanks.

bambirombi avatar May 07 '22 15:05 bambirombi

  • While using your file manager, a terminal will be shown briefly. To establish good contact, you should know which one you typically use; examples are e.g., the gnome-terminal, xfce4-terminal. In case you may access multiple, identify the one called by default. Speaking for Linux Debian 12/bookworm (branch testing) with xfce4, the pull-down menu settings -> default applications -> utilities offers you a GUI to identify/adjust this.

    According to askubuntu, the command ps -o 'cmd=' -p $(ps -o 'ppid=' -p $$) issued in your terminal equally provides you this information.

  • You install Nautilus; speaking for Linux Debian, this is complemented by the packages nautilus-scripts-manager and nautilus-extension-gnome-terminal; synaptic will resolve the dependencies. Because this is about installing packages, this step requires elevated privileges on the system you are using.

  • While running in a normal user profile, you create a repository for all additional scripts Nautilus eventually should provide access via its GUI. In your terminal, issue the command

    $ mkdir -p ~/.local/share/nautilus/scripts
    

    to create such a folder.

  • If not already done, install Karl's scripts to add time stamp, tag, appended note, move2archive; guessfilename etc. now. For me, the most convenient way to get them running at all was via PyPi; depending on your familiarity with Linux, your mileage may vary.

  • Copy-paste a script like the one below into /.local/share/nautilus/scripts. As an illustration, I just copied

    /usr/bin/xfce4-terminal  \
     --geometry=85x15+330+5  \
     --hide-menubar  \
     -x filetags --interactive "${@}" %F
    

    as file tagon.sh into this folder to assign the tags to all files selected (%F). Note the first line which suits me using xfce4-terminal which however need not the terminal you are using (vide supra). The backslashes used (\) serve only the purpose to ease managing/adjusting the parameters (e.g., if you are using a wider screen). Close Nautilus. To «activate» the script, enter the folder from the terminal and offer the executable bit to the script (for the specific example, chmod u+x tag_on.sh)

  • You are done. Open Nautilus, mark the file to be tagged by left-hand mouse bouton, activate the the pull-down menu by the other mouse key on the right, etc.

    nautilus

    Over time, you probably want to access Karl's scripts again an again yielding a collection of entries adjusted to your needs. E.g., by an additional script

    /usr/bin/xfce4-terminal  \
      --geometry=85x15+330+5  \
      --hide-menubar  \
      -x filetags --interactive --remove "${@}" %F
    

    to remove tags erroneously attributed. Or to access those where an interaction with a GUI suits your needs:

    example_thunar_01


  • note 1): I do not know nautilus well enough if the definition of short-cuts -- as seen in Thunar -- is possible:

    example_thunar_02

    For me, this is a handy acceleration.

  • note 2) Similar to Karl's presentation (GLT18 video recording), I like to access his scripts from geeqie. The approach is similar and works very well with many types of images, especially once one has set up short-cuts. For .pdf, geeqie displays the first page which often is enough to select the one of Karl's scripts suitable, too.

nbehrnd avatar May 07 '22 18:05 nbehrnd

Thanks!!! It worked. The only thing I would like to have is the scripts directly in the context menu as you have them in thunar. I have searched but have not found any way of doing that in nautilus. I have found https://stackoverflow.com/questions/47235022/add-a-custom-option-in-nautilus-right-click-menu the nautilus actions configuration tool, but it is the same, you cannot directly put it in the right click context menu. If you find any solution let me know!

ghost avatar May 07 '22 23:05 ghost

Not sure if there is an easier approach (like the one for thunar) in nautilus, I may have a look on this later arvo.

On the other hand, tagging per se is complemented by move2archive. Thus I would like to add the hint to Karl's post My Folder Hierachy with the following illustration:

2018-07-22 my folder hierarchy overview -- publicvoit - scaled width 560

This provides some additional valuable details I did not get right away (rightfully declined PR) from only watching the recording of Karl's talk at GLT18 (though the result is briefly shown in action at the end of his presentation). As a result, I now use two additional folders, ~/archive (containing the original data, the destination set by move2archive) and ~/.filetags_tagfilter/ (for the links). For convenience, I bookmarked both in Thunar and access the later when (not only if) not/no longer recalling the date a photo/a file was recorded. Not visible to the tree is the presence of a small bash script in ~/archive, basically

#!/usr/bin/bash

filetags --tagtrees --recursive --tagtrees-depth 3 --quiet

which is launched from time to time to update the content of ~/.filetags_tagfilter/.

Note, e.g., projects of source code are not so well suited to this method of organization; as a result, they stay better out of this management (a separate ~/src for share with GitHub really works fine). If new to the overall workflow, start during a calm weekend with some «cheap data» easy to recover into their original spot e.g., by restoring a backup. And like Karl stated, it isn't to replace, but to complement desktop search.

nbehrnd avatar May 08 '22 08:05 nbehrnd

I was trying to put also a shortcut for the script as you do. I do not know what I am doing wrong. I put in "command" the file path of the script: /home/username/.local/share/nautilus/scripts/tagon.sh When I use the shortcut the terminal opens, as when I use right click context menu and select the script, but, I put the tag and nothing happens. All works the same, but the script for whatever reason does not insert any tag to the file. Any idea?

Well, I have seen, as you say that with the script filetags --tagtrees --recursive --tagtrees-depth 3 --quiet It creates a link to .filetags_tagfilter. And I would like to know if you could help me with one script to do this simple thing (but that I have no idea how to do...): So, I put different files in a folder hierarchy, as everybody. Example (one file): /run/media/username/USB STICK/UNIVERSITY/YEAR 3/SUBJECTX/1.-Presentation.pdf . So I want to select that file and create a link to /run/media/username/USB STICK/WORK

The idea is to put the files in a hierarchy and link them to work, so, in that way, I can have in one folder (work) all the works that have to be finished, and then I would put the due date to each linked file in work folder (manually), so I could have some sort of prioritization and all of that in a unique folder, to not lose time searching for it in the hierarchies or in the search bar.

And I would also like to know, if there is any way to avoid breaking the link if you change the original filename, because what I see is that if for whatever reason you change the original filename, the link will be broken. So, in my case, there would be two ideal scenarios. One, to change the filename and to change the link filename, without changing the link filename date (or, optionally changing all the link filename to be the same as the original) and the second, to let the same filename to the link, not changing it in any way. But in both cases, obviously, not breaking the link.

ghost avatar May 08 '22 10:05 ghost

The approach most close to «drop the script to execute directly into a GUI like seen for thunar» apparently is/was nautilus action manager mentioned here, and filemanager-actions mentioned as a successor (here). Speaking for Linux Debian, I did not find them in the current repositories of bookworm (branch testing), or was not yet successful to get them up and working. (Maybe other distributions still/already distribute them.) On the other hand, there is no problem to install more than one file browser because it is possible to define one as the one used by default, and to launch an other from the CLI ( e.g., by thunar &, nautilus &, etc) just for the brief moment they are needed.

nbehrnd avatar May 09 '22 05:05 nbehrnd

Point 1, about «command» in thunar (assuming I understood you correctly):

My guess is, the concepts how thunar and nautilus interact with additional (user defined) actions and scripts differ. That is:

  • Once set up nautilus is set up with nautilus-scrip-manager, the file manager checks if there is a script in ~/.local/share/nautilus/scripts/. In case there is this folder, scripts will be displayed in nautilus's GUI by the script's file name.

  • Thunar's edit action/command approach anticipates the user to input only the bare command (as concept, think e.g., unzip test.zip because nothing is/needs to be displayed on a terminal). In case of a lengthier instruction, the anticipated input is the whole shell script (e.g., the tagon script where an intermediate terminal is needed). However (in contrast to nautilus), do not provide a pathway pointing to a script's deposit in a folder. Example thunar:

    2022-05-11_example_thunar

As long as actions by one file manager do not collide with actions simultaneously en route to provide the same result .or. simultaneously touch and alter the file/file name, there is no obstacle to have definitions to the same effect for either (i.e., for both/all) file managers installed on a computer.


point 2 about the date in the file's file name:

The addition of a time stamp into the name of a file/of a folder is provided by date2name. By default, it is the time of the last modification, but there is a switch to use the time of creation instead. In this perspective, the dates always refer to dates of the past. Time stamps on the file however may be altered by the touch command, e.g.

touch -d now example.txt
touch -d "10 Dec 1948" example.txt
touch -d "next tuesday" example.txt

The provision of an agenda/manage a list of priorities likely isn't what date2name was written for. (Emacs' orgmode, however, is an ecosystem which may assist you in this. Rainer König's video tutorials for example include a brief installment about this topic, see e.g., [1].)


point 3 , archiving whole archives

The addition of a time (date2name), or comment (appendfilename) changes the files' file names; if these are used to interconnect the files with each other, these links will break.

It is possible to retain files generated and modified on a different time of a day/a different day in one folder in common e.g., if you provide all (relevant) members of this folder the same tag(s) (filetags anyway suggests you to pick tags already used in the current working directory). Then 1) update the relative links among the files (if necessary), 2) add all of them their time stamp (date2name, which does not mind doing so if one file is from May, an other by last April and both in the same folder). 3a) Use either the oldest (in the example, the by April) or youngest to establish an entry in the archive established by move2archive and allow only the oldest file to be moved by this script and 3b) manually shuttle the more recent file(s) into the new spot of the archive (e.g., cp -a younger_file.txt ~/archive/the_new_destination). This approach works better for files which are self sufficient and where a small difference in regard of the stamped time does not matter much; the «business run with colleagues» in Karl's tree example is an illustration.

This approach however will not work well if it includes e.g., log data used to run/update a recurrent computation and the folder equally contains a script to gnuplot the eventual temperature diagram. This is be better organized in sub folders about untouched_rawdata, scripts, and results and managed with git; once completed, archive this whole project as a .zip altogether. (Some desktop search engines (like recoll) eventually may be set up to index .zip archives and their content.)

[1] https://www.youtube.com/watch?v=IofHvutUWV0

nbehrnd avatar May 11 '22 05:05 nbehrnd

@bambirombi @novoid For multiple months, there was no additional request for help here. Thus one may assume that problems were resolved successfully; thus the thread may be closed. In case @bambirombi wants to pick up the thread again, either re-open this discussion, or start a new one.

nbehrnd avatar Sep 12 '22 15:09 nbehrnd

Hi everyone! I'm trying to follow this guide to open a terminal with filetags from Nautilus. I got as far as setting up the Nautilus script with this: /usr/bin/kgx /bin/bash filetags "${@}" %F However, even though filetags works on a "manual" kgx terminal, the auto-opened terminal throws errors:

/usr/local/bin/filetags: line 3: PROG_VERSION: command not found
/usr/local/bin/filetags: line 31: from: command not found
/usr/local/bin/filetags: filetags: line 33: syntax error near unexpected token `('
/usr/local/bin/filetags: filetags: line 33: `def save_import(library):'

If I try to use python instead of bash like so /usr/bin/kgx /usr/bin/python /usr/local/bin/filetags it throws this:

Could not find Python module "clint".
Please install it, e.g., with "sudo pip install clint".

DeutscheGabanna avatar Oct 27 '23 21:10 DeutscheGabanna

Why didn't you create an independent ticket for that issue? To me, it seems a separate thing only connected by the Nautilus environment.

If I try to use python instead of bash like so /usr/bin/kgx /usr/bin/python /usr/local/bin/filetags it throws this:

Could not find Python module "clint".
Please install it, e.g., with "sudo pip install clint".

Well, it seems you're missing clint and it told you how to fix this. ;-) Did you install it with said command?

novoid avatar Oct 28 '23 09:10 novoid

Solved with #63

DeutscheGabanna avatar Oct 29 '23 16:10 DeutscheGabanna