Previous Post | Top | Next Post |
TOC
This is based on nautilus
version 43.2 in 2023 (Debian/Bookworm).
Gnome Files
“Gnome Files” (a.k.a nautilus
) is the default file manager for GNOME desktop
environment. It is rather a simple file manager with primitive
functionalities, but it can be extended to offer rich features.
gnome-terminal
started from nautilus
using extension
The nautilus-extension-gnome-terminal
package is automatically installed when
gnome-terminal
is installed and enables nautilus
GUI to start
gnome-terminal
CLI session. There are 2 ways.
- Left click “
⋮
"-icon at the right of directory box in the top bar. - Right click folder icon for directory in the right pane.
The current directory of started terminal is intuitively set by GUI.
You can copy file/directory paths selected on the GUI dialogue to the terminal prompt.
This is the most useful extension of nautilus
for me and is written in C++
using libnautilus-extension4
as its backend.
Practical extension
If you want to run a simple script on GUI selected files, practical approach is to use the simple script-type extension.
Here is an example to convert iPhone HEIC image into JPEG and Microsoft Word
document into PDF. You can see its execution log with journalctl -f
#!/bin/sh
__exec() {
systemd-cat -p 3 -t "${0##*/}" "$@"
}
if [ "$NAUTILUS_SCRIPT_CURRENT_URI" = "${NAUTILUS_SCRIPT_CURRENT_URI#file://}" ]; then
# not starting with file://
__exec echo "Not local path: '$NAUTILUS_SCRIPT_CURRENT_URI'"
else
echo "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | {
while true; do
read FILE_PATH
case "$FILE_PATH" in
*.HEIC | *.heic)
__exec heif-convert "$FILE_PATH" "${FILE_PATH%.*}.jpeg"
;;
*.doc | *.wri | *.rtf | *.odt | *.DOC | *.WRI | *.RTF)
__exec lowriter --headless --convert-to pdf "$FILE_PATH"
;;
"")
break
;;
*)
__exec echo "Unknown file: '$FILE_PATH'"
;;
esac
done
}
fi
This is very trivial coding and very handy extension of nautilus
.
My latest scripts are at: https://github.com/osamuaoki/nautilus-scripts
Extension methods explained
There are mainly 3 paths to extend nautilus
.
- Extension using
libnautilus-extension4
from C/C++ code - Extension using
python3-nautilus
from Python code - Extension using script interface of
nautilus
Extension using libnautilus-extension4
from C/C++ code
This is a full-featured extension. This requires serious learning before using.
Extension using python3-nautilus
from Python code
This is a full-featured extension. This requires less learning before using but it’s non-trivial.
You must install python3-nautilus
for this.
You can process selected files etc., by placing an extension Python code which
subclasses Nautilus.MenuProvide
to python3-nautilus
in
~/.local/share/nautilus-python/extensions
.
- Nautilus Python – upstream site
- Migrating to Nautilus API 4.0 (Nautilus 43)
- Nautilus extensions - how do you write them now G43? (2022) – links to examples
- How to write Nautilus extensions with nautilus-python (2022-10-03)
Due to recent changes of nautilus
and GTK(3->4), some published extensions
don’t function as expected. So this is non-trivial.
Extension using script interface of nautilus
This is a simpler and older interface to nautilus
.
You can run a script on selected files etc., by placing a script in
~/.local/share/nautilus/scripts
. nautilus
passes its selection
to script using the value of certain environment variables.
- How to extend the GNOME Nautilus file manager with custom scripts (2022-06-03)
- There is an example
organize.py
which organizes image files by the date information in EXIF.
- There is an example
- Ubuntu: NautilusScriptsHowto (2015-04-25)
Notable variables:
NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
NAUTILUS_SCRIPT_SELECTED_URI
NAUTILUS_SCRIPT_CURRENT_URI
NAUTILUS_SCRIPT_WINDOW_GEOMETRY
Review of extensions
There are many extensions. I am mostly using basic Debian packaged extensions only. Here are my thoughts on them. I may be incorrect.
libnautilus-extension4
-type extension- DEB:
nautilus-extension-gnome-terminal
– above mentioned (essential) - DEB:
nautilus-image-converter
– resize and rotate images (optional) - DEB:
seahorse-nautilus
– encrypt/decrypt files (optional) - Not-installed
- nautilus-annotations – Annotate files and directories
- nautilus-launch – launchers via right-click menu
- DEB:
python3-nautilus
-type extension- Nautilus-fileconverter-43 – convert images, audio files and video (convert HEIC or DOC files are not easy to be included in this)
- Not installed:
- DEB:
nautilus-admin
(stalled upstream) – nogedit
for root operation. - DEB:
nautilus-hide
(stalled upstream) – why hide? - nautilus-copypath and nautilus-copy-path – copy path, URI, name or content
- native “copy”-menu is sufficient for my needs
- outdated code for GTK4, not easy to fix properly. (Gtk->Gdk etc.)
- DEB:
- script-type extension
organize.py
may be adopted to use python3-nautilus
with some GUI to select
output directory style, or even adjust timestamps.
Reference sites
- Nautilus Scripts (2023-05-14)
- github topics: nautilus-extension (2023-04-14)
- 13 Ways to Tweak Nautilus File Manager in Linux to Get More Out of it (2023-04-07)
- 5 Nautilus Extensions to Enhance Your GNOME File Manager (2022-09-30)
Previous Post | Top | Next Post |