/NFC43

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

nautilus-fileconverter-43

A python script to extend Nautilus using nautilus-python.

NautilusConverter-1 drawing

0. ReadMe Contents

  1. Features
  2. Installation
    1. Install dependencies
    2. Optional dependencies
    3. Install the extension
  3. Configuration
    1. Automatic updates
    2. Shown menu items
    3. Other options
  4. Updating
  5. Usage
  6. Warnings and errors
  7. Any questions?
  8. Credits

1. Features

This program can convert images, audio files and videos with the help of the default context menu in Nautilus. It works with a single Python script and has few depnendncy programs. It should work with every version of nautilus.

    flowchart TD
    A[Supported Image Files]
    B[Supported Audio Files]
    C[Supported Video Files]
    D[image]
    E[audio]
    F[video]

    A["JPG<br/>JPEG<br/>JPE<br/>PNG<br/>BMP<br/>AI<br/>EPS<br/>PS<br/>GIF<br/>ICO<br/>PCX<br/>PPM<br/>TIFF<br/>TIF<br/>XBM<br/>FLI<br/>FPX<br/>BIN<br/>WMF<br/>XPM<br/>WEBP<br/>AVIF*¹<br/>HEIC*¹<br/>JXL*²"]
    B["MP3<br/>MPGA<br/>MPG<br/>MPEG<br/>WAV<br/>M3U<br/>M3U8<br/>M4A<br/>MKA<br/>AAC<br/>3GP<br/>3G2<br/>OGG<br/>OPUS"]
    C["MP4<br/>WebM<br/>MKV<br/>AVI<br/>MOV<br/>QT"]

    D["JPEG<br/>PNG<br/>BMP<br/>GIF<br/>WEBP<br/>JXL*²<br/>TIFF<br/>Different square sizes"]
    E["MP3<br/>WAV<br/>ACC<br/>FLAC<br/>M4A<br/>OGG<br/>OPUS"]
    F["MP4<br/>WebM<br/>MKV<br/>AVI<br/>MP3<br/>WAV"]

    A --> D
    B --> E
    C --> F

Needs pyheif.
Needs jxlpy.

2. Installation

2.1 Install dependencies

The extension has a few dependencies which have to be installed.

nautilus-python needs to be installed to install extensions:

   Debian based distros:
  sudo apt install python3-nautilus

  Fedora based distros:
  sudo dnf install nautilus-python

  Arch based distros:
  sudo pacman -Sy python-nautilus

pip is a pre-dependency for pillow, it can be installed with the following commands:

   Debian based distros:
  sudo apt install python3-pip

  Fedora based distros:
  sudo dnf install python3-pip

  Arch based distros:
  pacman -S python-pip

python-pillow is needed to convert images. It can be installed using pip:

    pip install Pillow

ffmpeg is needed to convert audio and video.

   Debian based distros:
  sudo apt install ffmpeg

  Fedora based distros:
  sudo dnf install ffmpeg

  Arch based distros:
  sudo pacman -S ffmpeg

GNOME's file viewer Nautilus should be installed, otehrwise it will be hard to install extension to it.

2.2 Optional dependencies

pyheif (HEIC, AVIF)

pyheif is needed if you want to convert from heif or avif format.
Install it using this command:

    pip install pyheif

jxlpy (JXL)

jxlpy is needed if you want to convert from jxl format.
Install it using this command:

    pip install jxlpy

Note: jxlpy is in a very early state, you may have issues while installing it using pip. You may need to install it manually.

2.3 Install the extension

  • Download the nautilus-fileconverter.py file from the release page.
    • Git users can also get the repository with these commands:
          git clone https://github.com/Lich-Corals/Nautilus-fileconverter-43
      
          cd ./Nautilus-fileconverter-43
  • For a system-wide installation move the file to '/usr/share/nautilus-python/extensions/' using this command in the dictonary with the file:
        sudo mv nautilus-fileconverter.py /usr/share/nautilus-python/extensions/nautilus-fileconverter.py
    • For a user specific installation move the file to '~/.local/share/nautilus-python/extensions/' using this command in the dictonary with the file:
          mv nautilus-fileconverter.py ~/.local/share/nautilus-python/extensions/nautilus-fileconverter.py
  • Now you only have to restart Nautilus using the following commands:
        #Quit nautilus
        nautilus -q
    
        #start it again, you can also use the normal launcher.
        nohup nautilus & disown

3. Configuration

The program can be configured using the NFC43-Config.json file, which will be created in the installation dictionary when the script is executed for the first time. Just modify the file, by changing the 'true' and 'false' values. If the program is installed in a root location, you need to change the configuration inside the script. Don't forget to save your changes, and restart nautilus after modifying the configuration!

    #Quit nautilus
    nautilus -q

    #start it again, you can also use the normal launcher.
    nohup nautilus & disown

3.1 Automatic updates

Automatic updates are only working in the home dictionary. If you've installed the script at the system-wide location, you may turn off automatic updates.

To turn off automatic updates, open the config file with a text editor and set the automaticUpdates variable to 'false'. To manually trigger a self-update, just open the .py file with a text editor and change the value of the converterVersion variable.

3.2 Shown menu items

To turn off the patch note button in the context menu, open the config file with a text editor and set the showPatchNoteButton variable to 'false'.

To turn off the Configure NFC43 button in the context menu, open the config file with a text editor and set the showConfigHint variable to 'false'.

To turn off the 'convert to square' option, open the config file with a text editor and set the convertToSquares variable to 'false'.

To turn off the 'convert to wallpaper' function, open the config file with a text editor and set the convertToWallpapers variable to 'false'.

3.3 Other options

To turn off the patch note pop-up, open the config file with a text editor and set the showPatchNotes variable to 'false'. To turn off the Double script installation Warning, open the config file with a text editor and set the checkForDoubleInstallation variable to 'false'.

4. Updating

If the script is installed in the home folder (~/.local/share/nautilus-python/extensions/) or has permissions to write in it's dictionary, it will update automatically as long as the automatic updates aren't disabled.

If automatic updates are disabled, you can run the installation commands again to update the program.

5. Usage

Just right click on an supported file and choose the "Convert to..." option. In this sub menu you can select any file type you want to convert to.

Converting a file can take some time. There is no indicator when the process is done.

If you experience any issues with the extension, please report it on the issues page.

6. Warnings and errors

WARNING(Nautilus-file-converter)(XXX):

(000): "pyheif" not found

Causes:
This warning is caused, because the script is not able to find your pyheif installation.

Possible Effects:
Without pyheif, the converter won't be able to convert from heif file format.

How to solve?
To solve this warning, you need to install pyheif using pip. View the Optional dependencies section to get installation instructions.

(001): "jxlpy" not found

Causes:
This warning is caused, because the script is not able to find your jxlpy installation.

Possible Effects:
Without jxlpy, the converter won't be able to convert from- or to jxl file format.

How to solve?
To solve this warning, you need to install jxlpy using pip.
View the Optional dependencies section to get installation instructions.

(002): No permission to self-update

Causes:
The program has no permission to write it's own file.
This warning usually occurs when the script is located at "/usr/share/nautilus-python/extensions/".

Possible Effects:
The self-update function will not be available.
The script may show the releases page on multiple startups if self-update isn't disabled.

How to solve?
To remove the release popup, you may disable the corresponding setting. To do this, please follow the instructions on the configuration page.
To get self updates, the script needs the permissions to write to itself. This can be done by changing the file permissions using chmod or by running the script as a privileged user.
To be able to self-update, the user, who is executing the script (by starting nautilus) needs permissions to edit the script itself.

(003): No permission to write configuration file

Causes:
The program has no permission to write in the dictionary where it is installed.
This warning usually occurs when the script is located at "/usr/share/nautilus-python/extensions/".

Possible Effects:
The self-update function may not be available.
The script needs to be configured by editing the script itself.
If self-updating is enabled, the script's configuration will reset when a update is performed.

How to solve?
To fix this, the script needs the permissions to write inside the folder, where it is located. This can be done by changing the folder permissions using chmod or by running the script as a privileged user.
To use the configuration file, the user, who is executing the script (by starting nautilus) needs permissions create and edit files inside the installation dictionary.

To prevent the settings from being reset, you can add a config file to the dictionary. Note that the file will not be update if new configurations are added.

(004): Double script installation detected

Causes:
The script is installed in a home location and finds another script with the same name in the root installation folder ("/usr/share/nautilus-python/extensions/").

Possible Effects:
The context menu may appear two times.

How to solve?
To solve this issue, you have to remove one of the files (in "/usr/share/nautilus-python/extensions/" or in "~/.local/share/nautilus-python/extensions/")

(005): Double script installation detected

Causes:
Automatic updates are enabled and there are updates available. This is not an error, just information to make problems easier to solve.

7. Any questions?

If anything is not clear...
If you have a problem...
If you need a specific feature...
If any of your files is not supported...
...feel free to write a GitHub issue!

8. Credits

Authors

Pull requests