Automating Custom File Operations with Krusader's Useractions

If you use x11-fm/krusader, here's a quick guide about how to set up its Useractions to execute your own custom operations on the selected files from a keyboard shortcut or the right-click menu.

Common Steps

The Useractions are set up via Krusader's main-menu option Useractions > Manage Useractions. This will open the Useractions Window.

At the Useractions Window, click the button with a plus symbol to create a new Useraction.

Common fields you must fill:

- Category: Select in which submenu of the right-click menu you want to place your Useraction.

- Title: Name your Useraction.

- Default shortcut: The key binding you want to assign to the operation if any.

If You Want to Execute an App

- Execution Mode: Normal.

- Command: The path of the executable file (you can use the which() command to find it out) usually followed by %aCurrent%
Example:
Code:
/usr/local/bin/pinta %aCurrent%

Optionally:
1) If you need to pass additional switches to the program, they normally go before %aCurrent%
2) If the program accepts multiple files as consecutive parameters, instead of %aCurrent% write %aList("Selected")%

If You Want to Execute a Custom Shell Script

- Execution Mode: Collect output (this is my recommendation).

- Separate standard error: Toggled (idem).

- Command: The path of your script usually followed by %aCurrent% if it only accepts one file or by %aList("Selected")% if it accepts multiple files as consecutive parameters. If it needs other switches, write them as you normally would.
Example:
Code:
~/padfile.sh %aList("Selected")%

How to Write your Custom Shell Scripts

The best way is to use a loop to process as files all the parameters received.
If you do this, you can use %aList("Selected")% in the definition of the Useraction.
You can find an example script attached (a certain LLM imp wrote it for me)

Otherwise, process only one file and use %aCurrent%

How to Use

If you set up a multiple-files action, it will execute on the selected files of the active panel.

If you set up a single file action, it will execute only on the current file of the active panel, disregarding the selected files.
 

Attachments

Back
Top