Ubuntu – Error when running script (‘compress-pdf’) in Thunar custom actions

pdfscriptsthunarthunar-custom-actionsxfce

I want to add the script 'compress-pdf' to Thunar custom actions.

The script is the one posted in this answer, made to resize pdfs. It is based on zenity.

It was made for Nautilus, but, as stated there, it 'does not depend on any custom Nautilus variables and can be used with pretty much any file manager out there that supports custom menu actions.'

I have added the script into a text file, made it executable, and added the path to it into Thunar custom actions with the name 'resize pdf'.

enter image description here

But, when right-clicking the selected pdf and running 'resize pdf', I get this error:

enter image description here

Why is that and how to fix it?

(Maybe the zenity script needs indeed adjustment to work in Thunar custom actions?)

Best Answer

The error is on line 150

if [ -z "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" ]; then

The variable NAUTILUS_SCRIPT_SELECTED_FILE_PATHS does not exist. You need to replace it by pdf_file defined on line 140.

New line 150:

if [ -z "$pdf_file" ]; then

The adjusted version of the script can be found here.