User-defined Tools
One of the nice things about using a gui file manager is being able to select several files, then do something to them e.g. rename or delete them.
But rename etc has to be built into the file manager. Wouldn't it be nice if it were possible to extend this idea to process selected files
using commands of your own. Well with 4Pane you can do exactly this. A user-defined tool can call any available commands or scripts, to which you can pass selected items as parameters.
Though you can run programs that don't need parameters, such as 'df -h', you'll usually want to use them. This is how:
- %s is replaced by a Single selected file or directory.
- %f is replaced by a single selected File only; directories are ignored.
- %d is replaced by a single selected Directory only; files are ignored.
- %a is replaced by All the items selected in the active pane.
- %b is replaced by a single selected item from Both of the file-views.
- %p will prompt the user for a Parameter to pass to the application at run-time.
These can be combined or repeated as appropriate e.g. "~/myscript %p %p %a" will prompt the user for two parameters, then pass these and all the currently selected items to myscript.
You will probably be able run applications with superuser privileges by putting kdesu or gksu before the command e.g. "kdesu kwrite %f".
Similarly, depending on your setup, you may be able to run commands in a terminal by prefixing "sudo ".
The available user-defined commands can be run from the Tools > Run a Program menu. Alternatively you can give a tool a keyboard shortcut: see Configuring Shortcuts.
Add a new tool
4Pane comes with a "starter-pack" of these tools, but the idea is to add your own. This happens in the first page of Options > Configure 4Pane.
The dialog starts with the "Add" page loaded. In the first box, type in the full command e.g. myscript %f %p.
If the command needs to run in a terminal e.g. df -h, tick the "Run in Terminal" tickbox below. Some terminal commands (again df -h is a good example) display their output in the terminal, then immediately close before you can read the results.
To prevent this, tick the "Keep terminal open" box.
In the second box type the label: the words that you want to be seen in the Tools menu; if you leave this blank, the command itself will be used.
Next you need to choose to which menu or submenu the command should be added. The default is Run a Program, but you can alse select any available submenus.
You can create a new submenu, or delete the currently selected one, using the buttons on the right.
Edit an existing tool
Click the "Edit a Tool" button near the top of the page. Select from the dropdown box the label of the tool to be edited;
the command and "in terminal" status will be shown below. When you have the correct tool selected. click the "Edit this Command" button.
You will then be able to alter any of the entries. When you've finished click the button again (it will have changed its label to "Click when finished").
Delete an existing tool
Click the "Delete a Tool" button near the top of the page. Select the tool to delete from the dropdown box, then click the "Delete this command" button.
An "Are you sure" dialog will appear, to allow you to change your mind.
Once the data has changed, the Apply and Cancel buttons become enabled. When you've finished all your alterations,
click "Apply" (or Cancel if you've changed your mind). Until you do this, the results are not saved.
If you've finished configuring, click "Finished" to close the Configure dialog.