Thursday, November 29, 2018

Performing spell-check via right-click in XFCE

Rev 11/30/18 (see Revision Notes)


XFCE's default text editor, Mousepad, doesn't have a spell-checker, but most types of Linux include Aspell, an excellent spell-checker which runs in the terminal. You could use LibreOffice Writer (typically included with XFCE) as a spell-checker, but it's a massive program which takes a long time to load and is cumbersome to use as a spell-checker, whereas Aspell is small, quick, and easy to use. The problem with Aspell is that to use it, you would normally right-click in the directory which contains the file to be spell-checked, select "open terminal here," and enter the command "aspell -c <filename>" or "aspell check <filename>," and it might be a pain to enter the filename. So, I decided to try to find a way to use Aspell to spell-check a file by simply right-clicking on the file and selecting "Spell-check" in the resulting menu. Fortunately, XFCE's file manager includes a "Custom Actions" feature which allows custom "bash" programs (bash is the command-line interpreter) to be added to Thunar's right-click menu. I'm not a bash programmer, and I couldn't find a pre-fabbed solution, so I flailed around until I stumbled onto a solution, which can be implemented as follows:


In Thunar (the XFCE file manager), click on Edit, then on Configure Custom Actions.

In the Custom Actions window which appears, click on the "+" button in the column of buttons on the right.

In the window which appears, enter the following in the designated fields (the command must be used exactly as shown, including the quotation-marks, unless you have a better solution):

name: Spell-check
description: perform spell-check with aspell
command: xfce4-terminal -e "aspell check %n" (This command causes Thunar to open the terminal and enter the command enclosed in quotes, with the name of the file of interest substituted for %n. This is necessary because Aspell runs in the terminal, meaning that it uses the terminal as its means of interacting with the user, which in this case is initially Thunar.)

In the Appearance Conditions tab, enter "*" into the File Patterns field and below, select Text Files only.

Click on OK, then click on Close in the Custom Actions window.

Close the file manager.

Open the file manager and navigate to the text file to be spell-checked.

Right-click on the text file and click on "Spell-check" in the menu which appears. That should do it.


Notes
Revisions

11/30/18 - Clarified and embellished the 1st paragraph and the passage "(This command causes Thunar....)."