<title>Setting the icons corresponding to the available keyboard
layouts</title>
<para>
The appearance of the system tray icons that represent keyboard layouts depends on the icon <emphasis>style</emphasis>. &kkbswitch; implements the following three styles:
<variablelist>
<varlistentry>
<term>Country flag</term>
<listitem><para>
This style displays a country flag corresponding to the currently selected layout.
Note that this was the only style in version of &kkbswitch; prior to 1.3.
</para></listitem>
</varlistentry>
<varlistentry>
<term>Language code</term>
<listitem><para>
This style displays the two-letter ISO language code corresponding to the currently selected layout. This style mimics &Windows; layout indicator.
</para></listitem>
</varlistentry>
<varlistentry>
<term>Flag and code</term>
<listitem><para>
This style displays the language code against the background of a country flag. This style mimics &kde;'s <application>kxkb</application> application.
</para></listitem>
</varlistentry>
</variablelist>
</para>
<para>The following table illustrates the look of &kkbswitch; tray icon menu with different icon styles.
The desired style can be selected in the <guilabel>Layout icon style</guilabel> combo box.
</para>
<para>
Note that &kkbswitch; will try hard to guess the correct flag and language code based on the name of the
keyboard layout (the names are configured in XKeyboard). For example, it will
display the US flag and/or "EN" language code for US/ASCII layout, German flag and/or "DE" language code for German layout,
Russian flag and/or "RU" language code for Russian layout, etc. If it cannot guess
an icon, it will display a "default" icon, which simply shows the layout's number.
Use the configuration dialog to customize flag icons: select a layout in the
<guilabel>"Available keyboard layouts"</guilabel> listbox and click
<guibutton>"Change icon..."</guibutton> button. You will be presented with "Pick icon" dialog box. There you will be able to select from the list of country flag pixmaps that are shipped with &kde;. If you'd like to use a custom image, click the <guibutton>"Browse"</guibutton> button in the bottom of the dialog box and browse for the image file you'd like to use. Note that the preferred size for layout icons is 21 by 14 pixels. If your image has different dimensions, &kkbswitch; will scale it appropriately, but the result might look not very good.
</para>
<para>
Note that changing the icon is not available for the Language Code style, which does not feature a flag.
</para>
<para>
If you have specified a custom icon for a layout, you can always go back to the standard icon (the one the &kkbswitch; has guessed) by clicking <guibutton>"Use Default Icon"</guibutton> button. This button will be enabled only when the layout selected in the <guilabel>"Available keyboard layouts"</guilabel> listbox has a custom icon.
</para>
</sect3>
<sect3 id="default-group">
<title>Specifying default layout</title>
<para>
You can mark one of the configured keyboard layouts as the default. The default
layout will be activated when &kkbswitch; starts up. To mark a layout as
default, simply select the layout in the <guilabel>"Available keyboard
layouts"</guilabel> listbox and click <guibutton>"Set as default"</guibutton>
button. The default layout's name is shown in boldface in the
&kkbswitch; supports three modes of operation with regards to the scope of the active keyboard layout. Possible settings are:
<variablelist>
<varlistentry>
<term>All windows</term>
<listitem>
<para>
In this mode the active layout applies to all windows on your desktop. In other words, at any given time all windows use the same layout.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Windows of one application</term>
<listitem>
<para>
In this mode the active layout applies to windows one application<footnote><para>A technically inclined user familiar with &X-Window; API would be interested to know that &kkbswitch; considers windows that have the same Window Class (from WM_CLASS property) as belonging to the same application.</para></footnote>. In other words, each application has its own active layout. When a window gets focused, KKBSwitch automatically shows the active layout of this window's application in the system tray. When you change the active layout, either by pressing XKeyboard's group switch key, or by clicking KKBSwitch's tray icon, or by using its context menu, this change affects only the currently active application. Other applications retain their layouts.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>One window</term>
<listitem>
<para>
In this mode the active layout applies to the focused window only. In other words, each window has its own active layout. When a window gets focused, KKBSwitch automatically shows this window's active layout in the system tray. When you change the active layout, either by pressing XKeyboard's group switch key, or by clicking KKBSwitch's tray icon, or by using its context menu, this change affects only the currently focused window. Other windows retain their layouts.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
<para>
Pick the mode that you prefer in the <guilabel>"Layout applies to"</guilabel> combo box. The author's opinion is that "Windows of one application" is the most reasonable choice, but opinions vary.
</para>
<para>
Note that in "Windows of one application" and "One window" modes, all new windows start up with the default layout. In "All windows" mode new windows start with the active (global) layout.
</para>
</sect3>
<sect3 id="toggle-mode">
<title>Using "Toggle Mode"</title>
<para>
"Toggle mode" is a convenient feature of &kkbswitch;, which is useful if you
have more than 2 layouts. When "Toggle mode" is on, pressing the XKeyboard's
group switch key or clicking &kkbswitch;'s tray icon will toggle between the
two most recently used layouts. To activate the third or the fourth (if
available) layout
you'll need to right-click &kkbswitch;'s tray icon and select the desired
layout from the menu or use keyboard shortcuts (see <xref linkend="shortcuts"/>). For example, I have US/ASCII, Russian and Ukrainian
layouts configured. Most of the time I use either US/ASCII or Russian layout and
switch back and forth between them without activating the rarely needed
Ukrainian layout. But sometimes I need to write something in Ukrainian, so I
select this layout from the tray icon's menu.
</para>
<para>
To turn the "Toggle mode" on and off use the <guilabel>Use "Toggle
Mode"</guilabel> checkbox in the configuration dialog.
</para>
<para>
When "Toggle mode" is on, the two most recently used layouts will be marked
with an asterisk in the &kkbswitch; tray icon's menu.
</para>
</sect3>
<sect3 id="autostart">
<title>Starting &kkbswitch; automatically when you log in</title>
<para>
Use <guilabel>"Autostart"</guilabel> checkbox to enable &kkbswitch; autostart feature. When this checkbox is on, &kkbswitch; will start automatically each time you log in to &kde;. Note that this is independent of &kde;'s session restoration feature. If you configure &kde; to restore the previous session on login (under &kde; Components | Session Manager in &kcontrolcenter;), and &kkbswitch; was running in your previous session, &kde; will restore &kkbswitch;
in the new session regardless of the autostart setting.
&kkbswitch; allows you to quickly activate particular layouts with keyboard shortcuts. This is configured at the <guilabel>Shortcuts</guilabel> page.
The <guilabel>"Use shortcuts to activate keyboard layouts"</guilabel> checkbox allows to turns the shortcut feature on and off. Uncheck the checkbox if you don't want to use shortcuts at all. If the checkbox is checked, the shortcuts are enabled. You can configure what key combinations activate which layouts at the key chooser pane under the checkbox. This is a standard &kde; key chooser widget that should be familiar to you from other &kde; applications. The default shortcuts are: <keycombo action="simul"><keycap>Ctrl</keycap> <keycap>Alt</keycap> <keycap>1</keycap></keycombo> to activate the first layout, <keycombo action="simul"><keycap>Ctrl</keycap> <keycap>Alt</keycap> <keycap>2</keycap></keycombo> the activate the second one, etc.
</para>
</sect2>
<sect2 id="group-names">
<title>How &kkbswitch; guesses icons for keyboard layouts</title>
<para>
&kkbswitch; uses the name of the keyboard layout, as defined by XKeyboard, to
guess the icon to represent it. The process is entirely automatic; this section
is only for those who want to tweak how this guessing works or just are curious.
The algorithm is very simple. The &kkbswitch; distribution contains a file named
<filename>group_names</filename>, which resides in &kkbswitch;'s data directory
The file is a standard &kde; config file. It contains two sections. The secion named "Mapping" contains mappings from XKeyboard group names to country codes.
It contains various key=value pairs, key being the name of the XKeyboard layout and
value the two-letter country code of the flag to display. The second section, "Language" contains similar mappings from XKeyboard group names to language codes. Note that if a group name is not found in the "Language" section, it is looked up in "Mapping" section, thus only layouts where country code and language code do not coincide need to be listed in "Language" section (e.g. for US/ASCII group the country code would be "us", but the language code would be "en").
</para>
<para>
Once the country-code
has been determined, &kkbswitch; will look for an icon named
<filename>flag.png</filename> in the directory <filename
class="directory">$<envar>TDEDIR</envar>/share/locale/l10n/<replaceable>country code</replaceable></filename> for icons styles that feature a flag and use the language code for styles that feature the a language code.
As I was told, in &RedHat; 9 systems, the &kde; default country flag icons are missing. To work around that, if &kkbswitch; cannot find country flag icons in the location specified above, it will look for <acronym>GNOME</acronym>'s <application>gkb</application> icons in <filename class="directory">/usr/share/pixmaps/gkb</filename>. Unfortunately, <application>gkb</application> icons have size 40x60, while &kde; ones are 21x14. Thus &kkbswitch; rescales <application>gkb</application> icons on the fly, and the quality of the resulting images leaves a lot to be desired. But still it's better than nothing.
</para>
<para>
Of course, you can override the flag icon selection algorithm by specifying the icon you want to use, as described in <xref linkend="specifying-icons"/>.
</para>
</sect2>
</sect1>
</chapter>
<chapter id="developers">
<title>Developer's Guide to &kkbswitch;</title>
<para>
&kkbswitch; can be manipulated programmatically via DCOP. It exports an
interface named <classname>KBSwitchIntf</classname>. The interface offers the
configuration for the default layout and per-window layouts
</para>
</listitem>
<listitem>
<para>
Rashid N. Achilov <email>achilov@granch.ru</email> - made a FreeBSD port, suggested "Browse" button in "Pick icon" dialog box.
</para>
</listitem>
<listitem>
<para>
Vadim Kriklivy <email>analitic@vinnitsa.com</email> - suggested "Language code" icon style (a la &Windows;) and shortcuts feature, made Ukrainian translation.
</para>
</listitem>
<listitem>
<para>
Sergey V Turchin <email>zerg@altlinux.org</email> - implemented autostart feature.
Petko Yotov <email>5ko@free.fr</email> - contributed Bulgarian translation.
</para>
</listitem>
<listitem>
<para>
Michal Bukovský <email>michal@trilogic.cz</email> - contributed Czech translation.
</para>
</listitem>
</itemizedlist>
</para>
<para>
Documentation copyright 2001-2005 Leonid Zeitlin <email>lz@europe.com</email>
</para>
<!-- TRANS:CREDIT_FOR_TRANSLATORS -->
&underFDL; <!-- FDL: do not remove. Commercial development should -->
<!-- replace this with their copyright and either remove it or re-set this.-->
<!-- Determine which license your application is licensed under,
and delete all the remaining licenses below:
(NOTE: All documentation are licensed under the FDL,
regardless of what license the application uses) -->
&underGPL; <!-- GPL License -->
</chapter>
<appendix id="installation">
<title>Installation</title>
<sect1 id="getting-KKBSwitch">
<title>How to obtain &kkbswitch;</title>
<para>
&kkbswitch; has a home page at SourceForge:
<ulink url="http://kkbswitch.sourceforge.net">
http://kkbswitch.sourceforge.net</ulink>. Check there for the latest news. The latest version is available for download from the project page: <ulink url="http://sourceforge.net/projects/kkbswitch">
<option>--prefix</option>=<replaceable>dir</replaceable> - set the prefix where your &kde; installation is located. Alternatively, you can set $<envar>TDEDIR</envar> environment variable to the &kde; directory. Under regular circumstances, the configuration script will find the &kde; location automatically; use this option only if you are having problems without it.
<option>--enable-ru-ua-layout</option> - install the Russian/Ukrainian layout file (described in <xref linkend="ru_ua"/>). This option is useful for users of XFree86 prior to version 4.3, who want to use Russian/Ukrainian layout file. Note that with this option it is not possible to install &kkbswitch; without root privileges, because the layout file <emphasis>must</emphasis> go to the system XKB layout directory where ordinary users don't have write access.
</member>
<member>
<option>--without-arts</option> - do not check for &arts; development headers. &arts; is &kde;'s multimedia framework, which &kkbswitch; does not use. However, since &kkbswitch; uses standard &kde; configuration macros, the configuration script will check for &arts; headers and complain if they are not found. If this happens to you, specify this option to compile &kkbswitch;. Alternatively, install &arts; development headers, you'll need them one day.
</member>
</simplelist>
<para>
Since &kkbswitch; uses autoconf and automake you should have not trouble
compiling it. &kkbswitch; was tested under several versions of &Linux; and FreeBSD,
and a FreeBSD port is available.
</para>
<para>
If you system uses <application>RPM</application> you may want to download
&kkbswitch; source RPM package. To build a binary RPM out of source RPM run this
Note that with older versions of <application>RPM</application> you will need to use command <userinput><command>rpm</command> <option>--rebuild</option></userinput> instead of <userinput><command>rpmbuild</command> <option>--rebuild</option></userinput>
For the benefit of Ukrainian users of &kkbswitch; and XFree86 versions before 4.3,
a Russian/Ukrainian keyboard layout file is included with the distribution (users of XFree86 4.3 and later, including X.Org server, read the note in the end of this appendix). This file is experimental, so report any problems with it to the author of &kkbswitch;. The file is named
<filename>ru_ua</filename> and by default gets installed to the directory
<filename class="directory">/usr/X11R6/lib/X11/xkb/symbols</filename>, where
this type of XKeyboard configuation file is supposed to go. The file defines a
configuration with 3 keyboard groups (layouts): US/ASCII, Russian and Ukrainian.
To use this layout, you can do one of the following.
<orderedlist>
<listitem>
<para>
If you feel comfortable editing your <filename>XF86Config</filename> file and
know its structure you can simply edit the file (usually
<filename>/etc/X11/XF86Config-4</filename> for XFree86 4.x), and in InputDevice
section for keyboard set XkbLayout option to "ru_ua". It is recommented to set
XkbVariant to "winkeys", since only this variant was tested.
</para>
</listitem>
<listitem>
<para>
If you are using &RedHat; &Linux;, you may create a file named
<filename>.Xkbmap</filename> in your home directory and write the text "ru_ua"
(without quotes) in it. The default X session startup script will pick this file
and activate the layout named in it.
</para>
</listitem>
<listitem>
<para>
Run the command <userinput><command>setxkbmap</command> ru_ua</userinput> either
manually from command prompt our in one of your X session startup script.
</para>
</listitem>
</orderedlist>
</para>
<note>
<para>Users of XFree86 4.3 and later versions, including X.Org server, don't need any additional files if they want a three-language layout. Just specify <userinput>XkbLayout "us,ru,ua"</userinput> in your <filename>XF86Config</filename> (<filename>xorg.conf</filename> for X.Org server) file.