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?
I think I figured it out. I needed to have the
%f
flag in theParameters
field on theCommand
tab. TheExample
field shows you what command will be launched based on the parameters you use (seeLegend
for a list of the parameters). The%f
directedNautilus Actions
to issue the command after the path on the selected file.Here is a picture:
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 putlpr
in thePath
on theCommand
tab and the parameter%f
. This issues the commandlpr /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):
srm -lrz ~/.local/share/Trash/*/*
; Parameter>none (note: NA will move the part after srm to the Parameter)lpr
; Parameter>%f
/opt/Scripts/edit-as-root.sh
; Paramter>%f
convert
; Parameter>%f %w.pdf