|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
emFileMan Customization Copyright © 2008-2011,2016 Oliver Hamann. Homepage: http://eaglemode.sourceforge.net/ Contents1 Introduction2 File types and applications 2.1 Setting the preferred application for a file type 2.2 Adding a new application for a file type 3 Reference 3.1 Properties of commands and groups 3.2 Precedence of default commands 3.3 Utility functions 3.4 Arguments 3.5 Environment variables 3.6 The file manager's emMiniIpc server 1 IntroductionThis document describes how to customize the commands of the Eagle Mode File Manager. The commands are made of small script files. On Linux/UNIX, these files are written in the Perl programming language, and on Windows, they are written in Javascript. But for simple modifications, you do not need to know anything about these languages.The script files are located in the directory $EM_DIR/etc/emFileMan/Commands (replace $EM_DIR by the installation directory of Eagle Mode, and replace etc by etcw if on Windows). Commands of subgroups are located in corresponding subdirectories. You could modify the commands directly there, but this may require administrator privileges. Alternatively, you could create a copy of the whole directory tree, so that it is possible to modify the files with user privileges. The required path for that copy is $HOME/.eaglemode/emFileMan/Commands (or on Windows: %APPDATA%\eaglemode\emFileMan\Commands). If that directory exists and seems okay, the script files are loaded from there, and the other is ignored. Adding a new command simply consists of adding a new script file. To make a change visible to Eagle Mode, trigger the button Reload Files. Error messages for bad script files are printed to STDERR, and therefore it is a good idea to run Eagle Mode from a terminal while working on the commands (exception: on Windows the messages are written to %TMP%\emCoreBasedAppLog.log). Remember to make backups of your modifications, because they could be removed when reinstalling Eagle Mode. 2 File types and applicationsThis chapter is about modifying the mapping of file types to applications. But that is described only for Linux/UNIX here. There, Eagle Mode has one file manager command for each application. On Windows, there is just one command for all: "Open or Run". It is the default action for all files and it uses the mapping from the operating system, so that you can configure there (see Windows Control Panel -> Default Programs). Yes, it would be possible to create such an "Open or Run" command also on Linux/UNIX, which forwards to a central default program service - if you have one.2.1 Setting the preferred application for a file typeFor example, if you want to make Kate the default text editor, edit the file PlainText/Kate.pl (below the Commands directory described above) and find the following line in it:# Order = 2.0 Simply set the order number to zero: # Order = 0.0 Thereby, Kate gets precedence over all the other text editors. And besides, the button moves to the beginning of the group. 2.2 Adding a new application for a file typeAssumed you have an application that can edit or show files of a certain file type, and you want to be able to run it out of the file manager. Then you have to create a new file in the desired group directory. Give it a name that ends with .pl and fill it with this template:
And then replace three things in the template:
If you want to be able to open multiple files at once, and if supported by the application, you could replace, in the last line of the script, the word OpenSingleTargetFileWith by OpenTargetFilesWith. 3 Reference3.1 Properties of commands and groupsEach command script file has a special section containing properties. And for each command group directory, there is a file which even has such a section. The properties are configuration parameters read and used by the file manager.The format of the properties section is:
#[[BEGIN PROPERTIES]] On Windows, i.e. with Javascript, the section has to be enclosed in a Javascript comment (/*...*/). Possible properties are:
3.2 Precedence of default commandsBy setting the DefaultFor property, you can make a command the default command for a file type. But if multiple commands are the default for the same file, there is a conflict. In that case, the file manager chooses a command by the following rules (strongest-first):
3.3 Utility functionsAt the beginning of each command script, there is some code which loads and executes a framework. It is the file $EM_DIR/res/emFileMan/scripts/cmd-util.pl on Linux/UNIX, and %EM_DIR%\res\emFileMan\scripts\cmd-util.js on Windows. This performs some initializations and defines a lot of of utility functions. For information about these functions, please have a look into that file, and take all the existing command scripts as usage examples.The rest of this document may be of interest only for understanding the implementation of the framework, or for writing a new framework in another scripting language. 3.4 ArgumentsThe file manager calls the command scripts with certain arguments: The first argument is the number of source-selected files and the second argument is the number of target-selected files. Then there are the absolute paths of the selected files, with one argument per file, and with the source-selected files first.3.5 Environment variablesWhen the file manager calls a command script, following environment variables are set in addition to normal variables:
3.6 The file manager's emMiniIpc serverA command script can send certain requests to the file manager. For doing that, the script can execute the program emSendMiniIpc in the directory $EM_DIR/bin. The first argument must be the server name (say $EM_FM_SERVER_NAME), and all further arguments are making up the request, which can be one of these:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|