2

I wanted to move some of the Nautilus scripts, like print, edit as root, convert to pdf from the "Scripts" folder in the contextual menu (~/.local/share/nautilus/scripts) to their own entry.

When I select a sample file and run the script "edit as root" from the contextual menu>Scripts>Edit as root entry, it works.

#!/bin/bash
path=$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
path=${path%?}
quoted="file://$path"
gksu gedit "$@"

When I create a Nautilus-Actions Configuration Tool entry for the same exact script (same file, same location) and select the same exact sample file, it opens a blank file.

I've tried this with printing too. Same result. It has something to do with designating the file that is selected. But that seems weird since I am running the same exact script, just via Nautilus-Actions.

How do I tell Nautilus-Actions to run the scripts, using the selected file?

2

I think I figured it out. I needed to have the %f flag in the Parameters field on the Command tab. The Example field shows you what command will be launched based on the parameters you use (see Legend for a list of the parameters). The %f directed Nautilus Actions to issue the command after the path on the selected file.

Here is a picture: enter image description here

This works using the script in my question for edit as root.

To Print, it is really easy -- no script needed (and I couldn't get any of the scripts to work) -- all you need to do is put lpr in the Path on the Command tab and the parameter %f. This issues the command lpr /path_to_file.

So the problem I was having appears to be (1) I didn't designate the path for the script to work on and (2) although the print scripts I was using are self-contained (they don't function with a path after them) they didn't seem to want to work with or without the %f parameter. I still don't understand this.

Here are the entries that I use for my NA (in case others find them useful):

  • (A) Secure empty trash: Path>srm -lrz ~/.local/share/Trash/*/*; Parameter>none (note: NA will move the part after srm to the Parameter)
  • (B) Print: Path>lpr; Parameter>%f
  • (C) Edit as root: Path>/opt/Scripts/edit-as-root.sh; Paramter>%f
  • (D) Convert to pdf: Path>convert; Parameter>%f %w.pdf

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.