OmegaT for GNU/Linux comes with a nifty launcher that gives you a comprehensive GUI to most of the startup parameters without needing to do anything on the command line. Along with that I’m not sure that many Linux user use this script. I think, one of the reasons for that is that the script doesn’t save your choices and you have to enter them at each run, which isn’t too bad if OmegaT was installed by the provided installation script (a rare case, as far as I can tell). And then the launcher is written in a somewhat obscure scripting language that requires some familiarization if the defaults are to be edited. In this article I’ll show which parts of the code correspond to the respective GUI elements and what can be edited to make this script customized.
The “master” copy of the script that is going to be modified, is found inside OmegaT archive (in all three versions that can run on Linux: with 32-bit JRE, with 64-bit JRE, and without JRE). For you convenience it’s also listed here (that way even if the line numbering in the standard script ever changes due to updates and edits, here you could see what the instructions are about). The modified version can be saved in $HOME/bin/omegat
and made executable. Or it can be saved anywhere as long as you know how to run it. In any case you’ll need kaptain to run it, but it’s installable in most Linux distributions from the standard repositories.
All you need to edit the script is a text editor that shows line numbers. It’s unlikely that your text editor will have kaptain syntax highlighting, but you can use syntax highlighting for shell scripts which will make it a bit easier to read and navigate.
-
omegat.kaptn
#!/usr/bin/kaptain # This version of the Kaptain OmegaT Launcher: 2014-05-13 start "OmegaT Launcher" -> omticon top bottom ; top :tabbed -> locs mem langs connect appearance about ; bottom :horizontal -> button_bar ; omticon -> @icon("images/OmegaT.png") ; ### Locations tab locs :framed :vertical "Locations" -> javaloc jarfileloc optloc ; # Location of the Java runtime environment javaloc "Java runtime environment" -> java_list |! java_pick ; java_list :horizontal "System-wide Java installation" -> @combow ("/usr/bin/java", `ls /usr/lib/jvm/*/jre/bin/java`) javaloc_help ; java_pick :horizontal "Custom Java installation" -> @infile("java")="/opt/omegat/jre/bin/java" ; javaloc_help :dialog "Help" -> javaloc_m javaloc_hc ; javaloc_m :horizontal -> javaloc_t ; javaloc_t "The current default assumes that you have used the linux-install.sh\n installation script and are using a local version of the JRE\n (i.e. you have installed OmegaT with JRE).\n If you want to use a system-wide version of Java, you can either select \n \"System-wide Java installation\" (possibly choosing one of the versions \n from drop-down menu), or replace \"/opt/omegat/jre/bin/java\" with \"java\"\n (provided Java is in your execution path). If you are using a system-wide \n version of Java that is NOT in your execution path,\n replace \"/opt/omegat/jre/bin/java\" with the full path\n of your java executable (in quotes) or browse and select it." -> @ ; javaloc_hc :horizontal -> @close="Close"; # Location of the OmegaT.jar file (OmegaT version) # To make a particular OmegaT.jar file the default, replace ="" # with ="<full path of OmegaT.jar file>" jarfileloc :vertical "Location of OmegaT.jar" -> jarlist | ! jarpick ; jarlist :horizontal "System-wide OmegaT installation" -> @combow(`find -L /opt/omegat -name "OmegaT.*jar"`) jarfileloc_help ; jarpick :horizontal "Custom OmegaT installation"-> @infile("OmegaT.jar")="/opt/omegat/OmegaT-default/OmegaT.jar" @action(jvrs)="Ver."; jarfileloc_help :dialog "Help" -> jarfileloc_m jarfileloc_hc ; jarfileloc_m :horizontal -> jarfileloc_t ; jarfileloc_t "Location of the OmegaT program. This launcher defaults to the version\n installed with \"linux-install.sh\". You may use the drop-down menu \n to select one of OmegaT versions installed in /opt/omegat. You may also \n choose another version by browsing to and selecting the respective OmegaT.jar" -> @ ; jarfileloc_hc :horizontal -> @close="Close" ; jvrs -> "cd `dirname " jarfileloc "` ; \ echo \"#!/usr/bin/kaptain\" > /tmp/otver.kaptn ;\ echo \"start \'\"Version\"\' -> ver button \;\" >> /tmp/otver.kaptn ;\ echo \"button :horizontal -> @close=\'\"Close\"\';\" >> /tmp/otver.kaptn ;\ echo \"ver \'\"$(grep -o -m1 \"OmegaT\\s*[\.0-9]*[0-9 a-z]*\" \.\/changes.txt)\"\' -> @ ;\" >> /tmp/otver.kaptn ;\ kaptain /tmp/otver.kaptn && rm /tmp/otver.kaptn" ; # Optional file locations optloc "Optional locations" -> configloc projectloc ; # Specify non-default configuration files configloc :horizontal "Directory containing non-default configuration files" -> @directory configloc_help ; configloc_help :dialog "Help" -> configloc_m configloc_hc ; configloc_m :horizontal -> configloc_t ; configloc_t "Use a different set of configuration files to those in your \nsystem. Useful for example if you wish to use a colleague's \nsegmentation rules rather than your own." -> @ ; configloc_hc :horizontal -> @close="Close" ; # Open a specific project at launch projectloc :horizontal "Open specified project immediately" -> @combow("", `IFS=$(echo "\n\b") && for i in $(find $HOME -name "omegat.project" -type f); do echo "\"$(dirname $i)\""; done`) projectloc_help ; projectloc_help :dialog "Help" -> projectloc_m projectloc_hc ; projectloc_m :horizontal -> projectloc_t ; projectloc_t "Open a specific project immediately after launching OmegaT. \nUsualy superfluous in GUI mode." -> @ ; projectloc_hc :horizontal -> @close="Close" ; ### Memory tab mem :framed "Memory" -> memory ; memory "Assign memory limit for OmegaT" -> defm | halfg | oneg | twog | memory_help ; defm "Default" -> "" ; halfg "512 MB" -> " -Xmx512M" ; oneg "1 GB" -> " -Xmx1024M" ; twog "2 GB" -> " -Xmx2048M" ; memory_help :dialog "Help" -> memory_m memory_hc ; memory_m :horizontal -> memory_t ; memory_t "Determine how much RAM OmegaT is allowed to make use of. \nToo low a value will make large projects slow or impossible to open; too high a value \nwill prevent OmegaT from launching." -> @ ; memory_hc :horizontal -> @close="Close" ; ### languages tab # Selection of the user interface language # Add language codes (that OmegaT has) or delete them. # The first one on the list becomes the default langs :framed "Languages" -> UI ; UI "User interface" -> UIlang country languages_help ; UIlang "User interface language (nn)" -> @combow("en", "ar", "be", "ca", "cs", "cy", "da", "de", "el", "eo", "es", "eu", "fr", "gl", "hu", "id", "it", "ja", "nl", "pl", "pt", "ru", "sh", "sk", "sl", "sq", "sv", "tr", "uk", "zh") ; # Selection of the user country country "User country (NN)" -> @string(2) ; languages_help :dialog "Help" -> languages_m languages_hc ; languages_m :horizontal -> languages_t ; languages_t "Select the language of OmegaT's user interface. If no language \nis specified or a language is not available, OmegaT defaults first to the operating \nsystem language, then to English. Different country variants for the same language are not \nused at present." -> @ ; languages_hc :horizontal -> @close="Close" ; ### Connectivity tab connect :framed "Connectivity" -> proxy gt ms mymem team ; proxy "Proxy settings" -> proxyhost proxyport ; # Enter proxy host IP address proxyhost "IP address of your proxy server, if your system uses a proxy" -> @string ; # Proxy Server Port Number proxyport "Port number used by your system to access the proxy server" -> @string ; # Google Translate API key gt "Google Translate API key" -> @password gt_help ; gt_help :dialog "Help" -> gt_m gt_hc ; gt_m :horizontal -> gt_t ; gt_t "To use Google Translate within OmegaT, you must order \na password from Google and enter it here." -> @ ; gt_hc :horizontal -> @close="Close"; # Microsoft Translator API key ms "Microsoft Translator settings" -> msi msk ms_help ; msi "Microsoft Translator API Client ID" -> @password="" ; msk "Microsoft Translator API Secret Key" -> @password="" ; ms_help :dialog "Help" -> ms_m ms_hc ; ms_m :horizontal -> ms_t ; ms_t "To use Microsoft Translator within OmegaT, you must order \na client ID and a secret key from Microsoft Azure Marketplace \n(see https://datamarket.azure.com/dataset/bing/microsofttranslator) \nand enter them here." -> @ ; ms_hc :horizontal -> @close="Close"; # MyMemory MT email address mymem "MyMemory Machine Translation" -> mymem_em mymem_help ; mymem_em "Valid email address" -> @string="" ; mymem_help :dialog "Help" -> mymem_m mymem_hc ; mymem_m :horizontal -> mymem_t ; mymem_t "Provide your email address to be able to make \n1000 requests to MyMemory server a day \ninstead of 100" -> @ ; mymem_hc :horizontal -> @close="Close" ; # Team connectivity team :horizontal "Team connectivity for Team projects" -> !ton | toff | thelp ; ton "Sync with the server" -> " " ; toff "Disable sync" -> " --no-team" ; thelp :dialog "Help" -> team_m team_hc ; team_m :horizontal -> team_t ; team_t "With this option it is possible to temporarily disable synchronization\nwith the server for Team projects. To re-enable synchronization OmegaT\nneeds to be restarted with the appropriate option." -> @ ; team_hc :horizontal -> @close="Close" ; ### Appearance settings tab appearance :framed "Appearance" -> fontaa laf ; # Font anti-aliasing settings fontaa :double "Anti-aliasing settings" -> on | false | defaultaa | off | gasp | lcd_hrgb | lcd_hbgr | lcd_vrgb | lcd_vbgr | aa_help ; on "Anti-aliasing on" -> "on " ; false "Anti-aliasing false" -> "false " ; defaultaa "Anti-aliasing default" -> "default " ; off "Anti-aliasing off" -> "off " ; gasp "Use font's built-in hinting instructions" -> "gasp " ; lcd_hrgb "LCD monitor setting HRGB" -> "lcd_hrgb " ; lcd_hbgr "LCD monitor setting HBGR" -> "lcd_hbgr " ; lcd_vrgb "LCD monitor setting VRGB" -> "lcd_vrgb " ; lcd_vbgr "LCD monitor setting VBGR" -> "lcd_vbgr " ; aa_help :dialog "Help" -> aa_m aa_hc ; aa_m :horizontal -> aa_t ; aa_t "Fonts in Java on Linux can be very unattractive unless the optimum settings are selected. \nThe optimum settings depend upon the font type and size, your hardware, and the anti-aliasing \nsettings. The best anti-aliasing settings may differ according to the selected font \nand size and are best found by trial and error. It is worth taking time to experiment \nwith these." -> @ ; aa_hc :horizontal -> @close="Close"; # Look and feel settings laf "Look and Feel" -> deflaf | gtk | motif | laf_help ; deflaf "Default" -> " " ; gtk "GTK" -> " -Dswing.crossplatformlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel "; motif "Motif" -> " -Dswing.defaultlaf=com.sun.java.swing.plaf.motif.MotifLookAndFeel " ; laf_help :dialog "Help" -> laf_m laf_hc ; laf_m :horizontal -> laf_t ; laf_t "Modern Linux distributions attempt to create \na uniform look and feel, and you may notice little or no difference with these settings." -> @ ; laf_hc :horizontal -> @close="Close" ; ### About tab about :framed "About" -> general_t ; general_t "About the Kaptain OmegaT Launcher" -> @text (<<LONGTEXT Certain functions and settings of OmegaT are activated or configured at runtime, i.e. when OmegaT is launched, by means of command-line options. The Kaptain OmegaT Launcher is intended to make the use of these functions and settings easier for GNU/Linux users by providing a user-friendly user interface. Information on Kaptain and its syntax can be found at http://kaptain.sourceforge.net The Kaptain OmegaT Launcher is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. The text of the GNU General Public License is provided within OmegaT itself, with which this script is intended to be supplied. LONGTEXT ) ; ### Button bar button_bar :horizontal -> launch_button close_button ; launch_button -> @exec(omt)="Launch" ; close_button -> @close="Cancel" ; ### Launch command omt -> javaloc " -jar " memory " -Duser.language=" UIlang " -Duser.country=" country " -Dgoogle.api.key=" gt " -Dmicrosoft.api.client_secret=" msk " -Dmicrosoft.api.client_id=" msi " -Dmymemory.api.email=" mymem " -Dhttp.proxyHost=" proxyhost " -Dhttp.proxyPort=" proxyport " -Dawt.useSystemAAFontSettings=" fontaa laf " " jarfileloc " " projectloc " --config-dir=" configloc team ;
- Location Tab
- Line 18
javaloc "Java runtime environment" -> java_list |! java_pick ;
Putting the exclamation mark before the option makes it default. So, if “System-wide Java installation” is to be our default, we need to put!
beforejava_list
- Line 19
The list is built with what is specified between parenthesis in@combow ()
Items can be separated by comma, results of other commands may be used as items, for instance,`ls /usr/lib/jvm/*/jre/bin/java`
- Line 20
This path can be selected at the runtime using a standard filechooser, but to specify the default, find at the end of the line this part:
@infile("java")="/opt/omegat/jre/bin/java"
, and specify the the path of java executable of your custom Java installation. - Line 40
Similar to point 1, the default is changed by placing the exclamation mark before the option. - Line 41
Similar to point 2. This option can be very helpful if there are several versions of OmegaT installed on your system. By default it looks for OmegaT installations inside/opt/omegat/
(see this path in@combow(`find -L /opt/omegat -name "OmegaT.*jar"`)
), but that can be changed to reflect your installations, just change the path accordingly in that part of the line. Or simply list the full paths to your OmegaT installations (to OmegaT.jar files) , putting the paths in quotes and separating them by comma. It will produce your customized list. - Line 42
It’s very similar to point 3. Change the path as needed in this part of the line:@infile("OmegaT.jar")="/opt/omegat/OmegaT-default/OmegaT.jar"
- Line 65
If most of the times OmegaT needs to be started with its config directory not located in$HOME/.omegat
, this can be specified here by placing="/path/to/config/folder"
right after@directory
, so you’d have@directory="/path/to/config/folder"
- Line 73
By default the launcher script looks inside your home directory for every folder that contains a file namedomegat.project
, which is in most cases a mark of an OmegaT project. If you have a more specific location inside your home directory (like $HOME/Documents/Projects or $HOME/OmegaT Projects), or maybe it’s not in your home directory altogether, it can be specified here. Look for the part that says, “$(find $HOME -name "omegat.project" -type f)
“, and replace$HOME
with whatever directory you need. It searches for projects recursively. Changing this part of the script increases the startup speed because the script doesn’t have to dig through all the folders in your $HOME trying to find OmegaT projects. This line is a dropdown list made with@combo
, and items here are listed in quotes and separated by comma, so if there’s a project that you always want to start by default, it can be listed here too by adding"/path/to/default/project"
inside parenthesis in@combo()
- Line 83
You can change the default amount of memory allocated to OmegaT by placing an exclamation mark before the appropriate option.
- Line 104
Here we have a@combo()
again which builds a dropdown list. English (“en”) is put there first, and if you prefer another language for OmegaT UI, place its two-letter code in the beginning of the list.
- Line 124
Default proxy can be specified by putting="xxx.xxx.xxx.xxx"
or="super.proxy.com"
@string
. You would then have, for instanse@string="192.168.24.100"
- Line 128
Same as in previous point, but here only digits are expected. - Line 132
To store your Google API key so it doesn't need to be entered every time, place="youLongAndWeirdAPIstring_thatNobodyIsSupposedtoKnow"
after
@password
. The whole line will then look like this:
gt "Google Translate API key" -> @password="youLongAndWeirdAPIstring_thatNobodyIsSupposedtoKnow" gt_help ;
When the script is run,@password
will make your key look like a series of asterisks. - Line 143
- Line 144
These two lines are modified very much like point 3 in this section. Just don't confuse Client ID and API Secret Key. - Line 155
Email address can be specified the same way as proxy server and port in point 1 & 2 in this section. Just place it between the quotes after@string=
- There's not much to change here, but it might be worth it to make GTK a default Look-and-Feel for OmegaT. To do so, place an explanation mark before
gtk
in the line 197.
It's worth mentioning the the script was written by Marc Prior. Now the script is being maintained by other people, but without Marc's initiative we wouldn't have anything of this sort.
I hope this post will help some of the Linux OmegaT users to rediscover a very handy tool that has been sitting around all along, and to make a good use of it.
But as of now,
Good Luck, and God save Ukraine!
2 thoughts on “Customizing #OmegaT Kaptain Launcher (GNU/Linux)”