Thunar Custom Actions

The following Thunar Custom Actions represent many that I have used over the years. They come & go based on my current/ use needs. What can I say?

Catfish search:

<strong><em>catfish %f</em></strong>

Print file:

<strong><em>xfprint4 %f</em></strong>

Open Terminal Here:

<strong><em>exo-open --working-directory %f --launch TerminalEmulator</em></strong>

Edit as Root:

<strong><em>pkexec geany %f</em></strong>

Run in Terminal

<strong><em>xfce4-terminal -e %f --hold</em></strong>

Open Root Terminal:

<strong><em>pkexec xfce4-terminal</em></strong>

Replace filename space with dash

<strong><em>for file in %N; do mv "$file" "$(echo "$file" | tr -s ' ' | tr -s '-' | tr -c '[:alnum:][:cntrl:].' '-')"; done</em></strong>

Replace filename underscore with dash

<strong><em>for file in %N; do mv "$file" "$(echo "$file" | tr -s '_' | tr -s ' ' | tr -c '[:alnum:][:cntrl:].' '-')"; done</em></strong>

Open Root Here:

<strong><em>pkexec thunar %f</em></strong>

Edit as root:

<strong><em>pkexec [put-your-favourite-text-editor-here] %f</em></strong>

Open Terminal

<strong><em>xfce4-terminal --working-directory %f</em></strong>

Convert JPG to PNG

<strong><em>convert %F `basename %F .jpg`.png</em></strong>

Convert PNG to PNG

<strong><em>convert %F `basename %F .png`.jpg</em></strong>

Run Virus Scan
clamtk %F

PDF-DJVU & OCR

To make my pdf/ djvu/ ocr Thunar Custom Action functions work, you will need to install a few items that I use. The applications I use include:

  • pdfsandwich– “pdfsandwich generates “sandwich” OCR PDF files, i.e. PDF files which contain only images (but no editable text) will be processed by optical character recognition (OCR) and the text will be added to each page invisibly “behind” the images. pdfsandwich is a command line tool which is supposed to be useful to OCR scanned books or journals. It is able to recognize the page layout even for multi-column text. Essentially, pdfsandwich is a wrapper script which calls the following binaries: convert, unpaper, tesseract, gs, and hocr2pdf (if tesseract < 3.03). It is known to run on Unix systems and has been tested on Linux and MacOS X. It supports parallel processing on multiprocessor systems.” …. to preserve color use” References:
  • pdf2djvu– “It’s a known issue that PDF files containing many images can become horribly large. But there is a simple alternative to the PDF file format: DjVu files which use advance compression algorithms behave very much like their more popular big brother PDF, but convince with a reduced file size. “
  • pdf-to-djvu (script)- Is available in our KB “script” area.

All of the above applications need to be installed on your desktop. Use the recommended process for installing applications on your distriution.

The pdf-to-djvu (script) requires a slightly different process:

  • Download the script from this post by clickling the link (above)
  • Extract the script from the “zip archive”.
  • Copy the resultant script, called “pdf-to-djvu”, to the following directory: /usr/local/bin/ Make certain the script is “executable”.

Once these installations, download, and copy steps are completed, you will need to add two (2) Custom Actions to Thunar. (Note: If you don’t know how to do that the process is described here.)

After you have added these Custom Actions they should be fully functional. If you note any difficulty- simply log out & back in, that should make certain Thunar is reset and able to use your new commands.

Once the above tasks are completed, you will be able to:

  • Convert PDF documents To DJVU (Note: The resultant DJVU documents will be searchable even if the original PDF was not… this only works for English, so far as I know.)
  • Make a non-searchable PDF ‘searchable”. (Note: This only works for English, so far as I know.)

Convert PDF to DJVU:

<strong><em>xfce4-terminal -x pdf-to-djvu %f</em></strong>

Convert DJVU to PDF:

<strong><em>xfce4-terminal -x djvu-to-pdf %f</em></strong>

OCR PDF for Search

<strong><em>xfce4-terminal -x pdfsandwich -rgb %f</em></strong>

OCR DJVU file for Search

<strong><em>xfce4-terminal -x ocrodjvu --engine=tesseract --in-place %f</em></strong>