Last updated: 2005-04-28
This document describes steps you can take to fine-tune your GNU/Linux
system. It describes our experience with
localedef -i ru_RU -f koi8-r ru_RU.koi8r
LC_CTYPE=ru_RU.koi8r
LC_COLLATE=ru_RU.koi8r
export LC_CTYPE LC_COLLATE
(In place of ru_RU.koi8r, substitute your locale, which have to be built as described above. For the changes to take effect you have to logout/login.)
Note that you are better off using KOI8-R encoding. Don't mess with CP1251
(
First, recode is a great tool for converting between a hoard of encodings. When reading text files in non-native encoding, it is best used with a pipe:
recode cp1251..koi8r < file.txt | less
You can even write a small wrapper script around recode / less pipeline, if you have to often read files in some certain encoding.
Next, for editing files in CP1251 and CP866 (and many other encodings) you can use Emacs. See Russian Language Support / Emacs.
SYSFONT="koi8u_8x16"
SYSFONTACM="koi8-r"
and edit /etc/sysconfig/keyboard to have something like
KEYBOARDTYPE="pc"
KEYTABLE="ru1"
(You may have to use different names for font / keymap files.)
On your next reboot the script /etc/init.d/keytable will read and enable these settings. Which key is used to switch between Cyrillic / Latin layouts depends on the keymap you loaded. It is usually documented at the beginning of the keymap file. You can also create a custom keymap if you don't like any of the preinstalled keymaps.
set input-meta on
set convert-meta off
set output-meta on
(Read man 3 readline for their meanings.)
While we are at it, if that terminal bell is driving you nuts, you can turn it off by setting
set bell-style visible
Note that this will work only for programs which use readline to read their input from the terminal.
For creating and/or reading files with Cyrillic names on FAT and ISO9660 (filesystem for CDs) partitions you need to setup console (see Russian Language Support / Console) and filesystem drivers. To mount vfat or iso9660 partitions with Cyrillic filenames, give the driver the option
iocharset=XXXX
where XXXX stands for encoding name. For example, I use the following entries in /etc/fstab file to read and/or write files with Cyrillic names on floppies and CD's:
/dev/fd0 /mnt/floppy vfat user,noauto,iocharset=koi8-r 0 0
/dev/cdrom /mnt/cdrom iso9660 ro,user,noauto,iocharset=koi8-r 0 0
Note that to be able to use this option, you have to include Native Language Support (in `File systems' section) and select appropriate encoding when you are building your kernel. As far as I know, there is also (limited) support for NTFS, but I never tried it.
Emacs has its own mechanism for supporting international character sets. Whether you use Emacs or XEmacs, enabling Cyrillic support for your console / X Window is not sufficient if you want to have Cyrillic in Emacs.
Emacs internally uses a single multibyte character encoding, so that it can intermix characters from various encodings in a single buffer or string. When reading and writing files, Emacs translates between the multibyte character encoding and various other coding systems.
For interactive input, Emacs defines `input methods'. At the terminal, you may be typing Latin characters without using facilities that your console / X Window provides for entering Cyrillic, but input method currently in effect defines how Emacs translates these Latin characters into the multibyte character encoding Emacs uses internally.
For Emacs to correctly display text on your terminal, you also have to tell Emacs what character encoding your terminal uses. Emacs translates its internal multibyte encoding into this encoding when characters are output to the terminal (be it console or X Window terminal emulator).
One consequence of this scheme is that to use Cyrillic in Emacs, you don't even have to setup your terminal's keyboard for Cyrillic, you only need to have Cyrillic font loaded.
If you are using XEmacs, you can direct XEmacs to use the font you want either by adding the following line to your ~/.Xresources:
emacs*font: -misc-fixed-medium-r-normal--15-140-75-75-c-90-koi8-r
or by adding the following line to your ~/.emacs:
(cond (window-system (set-frame-font "-misc-fixed-medium-r-normal--15-140-75-75-c-90-koi8-r")))
(The latter setting overrides the former. Substitute name of your font -- remember it must support encoding that you select for terminal output, see below. If you choose the first method, you will have to restart X server for the setting to take effect.)
Emacs provides the following commands and variables for all these customizations:
See Emacs manual for more (if it is installed on your system, type info emacs).
All these commands / variables can be run / set in your Emacs initialization file, so that they are applied every time you start up Emacs. Add to your ~/.emacs the following lines:
(Adjust the coding systems. For the setting to take effect, restart
Emacs.)
Some useful commands related to the coding systems:
(set-language-environment 'Cyrillic-KOI8)
(set-terminal-coding-system 'koi8)
(set-keyboard-coding-system nil)
(setq default-buffer-file-coding-system 'koi8)
(set-selection-coding-system 'koi8)
(codepage-setup 1251)
This description applies to
Option "XkbDisable"
This will enable X keyboard extension which provides support for non-US keyboards. Then add
Option "XkbRules" "xfree86"
Option "XkbModel" "pc104"
Option "XkbLayout" "us,ru"
Option "XkbOptions" "grp:menu_toggle,grp:rwin_toggle,grp:switch"
This will provide two layouts (US and Russian), and make Menu and right Windows buttons on your Windows keyboard act as a toggle button for switching between the layouts, and right Alt as a (temporary) switch between layouts. If you are lucky enough not to have a Windows keyboard, you can set "grp:toggle" (right Alt) as a toggler for keyboard layouts. Check /etc/X11/xkb/rules/xfree86 for other possible combinations. For more information, read /etc/X11/xkb/README.config.
Also, don't forget to install Cyrillic fonts, if they are not yet installed.
I describe version 1.4.0.6. In Preferences dialog set
Open IM (input method)
and unset
Swap Delete/Backspace
Delete generates DEL/^H
Enable multibyte support
Meta sets the eighth bit
Also, choose a Cyrillic font in appropriate encoding.
For Russian language support, I downloaded xpdf-cyrillic.tar.gz and ran the commands (again, paths may vary)
tar xzf xpdf-cyrillic.tar.gz
cd xpdf-cyrillic
install -d /usr/share/xpdf/cyrillic
cp Bulgarian.nameToUnicode KOI8-R.unicodeMap /usr/share/xpdf/cyrillic
cat add-to-xpdfrc >> /etc/xpdfrc
If needed, edit /etc/xpdfrc and change paths /usr/local/share/xpdf/cyrillic/ to paths /usr/share/xpdf/cyrillic/.
If you want to have access to ghostscript fonts, edit /etc/xpdfrc and uncomment lines which start with displayFontT1 and change the paths to ghostscript fonts as appropriate (on Debian it is /usr/share/fonts/type1/gsfonts/).
I use teTeX (version 2.0.2) distribution. In this section, $TEXMF
stands for the path to your teTeX distribution (usually
/usr/share/texmf/). I describe how to setup Cyrillic support for use
with
Note that I describe how to build the required formats manually, which should work on most systems. However, some distributions provide tools which make life easier by running low-level commands automatically. For instance, in teTeX 2.0.2 there is a texconfig(1) configuration tool; many configuration files are centralized in /etc/texmf/ (see update-updmap(8), update-texmf(8), update-fmtutil(8)). After (re)configuring formats, you can run fmtutil(8), instead of manually running initex(1).
ftp://mch5.chem.msu.su/pub/russian/psfonts/
ftp://ftp.vsu.ru/pub/tex/font-packs/pscyr/
ftp://ftp.vsu.ru/pub/tex/literat.zip
ftp://ftp.vsu.ru/pub/tex/literat-*.tar.gz
If you install these fonts, make sure that references to map files for the new fonts are added to extra_modules variable in $TEXMF/dvips/config/updmap (or /etc/texmf/dvips/, /etc/texmf/updmap.d/ on newer systems).
In case of $TEXMF/dvips/config/updmap, add
extra_modules="
tli.map
pscyr.map
txr.map
"
for Literat, PSCyr and TXfonts packages respectively (the last one comes with teTeX). If your updmap does not already have the map file for Cyrillic Computer Modern (cmcyr.map) listed in common_modules variable, you can include it in extra_modules as well.
In case your system uses /etc/texmf/ hierarchy, add map files to /etc/texmf/dvips and put something like
Map tli.map
Map pscyr.map
Map txr.map
into /etc/texmf/updmap.d/, in a file, e.g.,
10mymaps.cfg, then run update-updmap(8).
type1_default=true
and rerun updmap. If your system uses /etc/texmf/updmap.d/00updmap.cfg instead, check that it contains a line `dvipsPreferOutline true' and run update-updmap(8).
russian ruhyphen.tex
ukrainian ukrhyph.t2a
\c wcm/t2a/txxdefs/cm/cyrcmfnt
and for cmcyr fonts in LCY encoding, add
\c xcm/lcy/txxdefs/cm/cyrcmfnt
Select hyphenation scheme (if you have not yet done so in 2.c), default input encoding for your documents, and whether you want to be able to switch input encodings:
\def\Pattern{ct}
\let\ifinpenc\iftrue
\def\definpenc{koi8-r}
\def\Ukrainian{\set@hyphenmins22\language\l@ukrainian}\let\Ukr\Ukrainian
tex --ini --fmt=cyrtex --progname=tex cyrtex.ini
and either place it in $TEXMF/web2c or make a link to it from there;
%&cyrtex
in the very first column of the very first line of your document, or run tex with parameters `tex --fmt cyrtex --translate-file=cp8bit'. Then, to select input and font encodings for you document, use for example
\inputencoding{koi8-r}
\fontencoding{T2A}
Note that cmcyr fonts do not contain Ukrainian glyphs. You can load other Cyrillic fonts, for example, Literat (see Cyrillic fonts for installation). At the beginning of your document, type
\font\tenrm=tlir6a at 10pt
\font\tenbf=tlib6a at 10pt
\font\tenit=tliri6a at 10pt
\font\tensl=tliro6a at 10pt
\rm
to replace the basic 10pt fonts.
The following works for pdfTeX version 3.14159-1.00a-pretest-20011114-ojmw (Web2C 7.3.7).
First, setup CyrPlain. Then:
pdftex --ini --fmt=cyrpdftex cyrtex.ini
and either place it in $TEXMF/web2c or make a link to it from there;
TEXINPUTS.cyrpdftex = .;$TEXMF/{pdftex,tex}/{plain,generic,}//
pdftex --ini mptopdf
pdfetex --ini mptopdf
and either place them in $TEXMF/web2c or make links to them from there (use mpost to produce postscript figures, then mptopdf to convert them into pdf figures; now you can insert them into your pdfTeX document -- see documentation);
Warning: pdftex (file /home/oleg/texmf/dvips/config/pdftex.map): invalid entry
for `rtxphvbo': SlantFont/ExtendFont can be used only with embedded T1 fonts
Warning: pdftex (file /home/oleg/texmf/dvips/config/pdftex.map): invalid entry
for `rtxphvro': SlantFont/ExtendFont can be used only with embedded T1 fonts
Warning: pdftex (file /home/oleg/texmf/dvips/config/pdftex.map): invalid entry
for `rtxptmbo': SlantFont/ExtendFont can be used only with embedded T1 fonts
Warning: pdftex (file /home/oleg/texmf/dvips/config/pdftex.map): invalid entry
for `rtxptmro': SlantFont/ExtendFont can be used only with embedded T1 fonts
you can edit $TEXMF/dvips/config/pdftex.map and replace the following lines
rtxphvbo Helvetica-Bold ".167 SlantFont TeXBase1Encoding ReEncodeFont" <tx8r.enc
rtxphvro Helvetica ".167 SlantFont TeXBase1Encoding ReEncodeFont" <tx8r.enc
rtxptmbo Times-Bold ".167 SlantFont TeXBase1Encoding ReEncodeFont" <tx8r.enc
rtxptmro Times-Roman ".167 SlantFont TeXBase1Encoding ReEncodeFont" <tx8r.enc
with this:
rtxphvbo Helvetica-Bold "TeXBase1Encoding ReEncodeFont" <tx8r.enc
rtxphvro Helvetica "TeXBase1Encoding ReEncodeFont" <tx8r.enc
rtxptmbo Times-Bold "TeXBase1Encoding ReEncodeFont" <tx8r.enc
rtxptmro Times-Roman "TeXBase1Encoding ReEncodeFont" <tx8r.enc
This is not really about Cyrillic, but anyway.
If you want dvips to output to a file by default but not to lpr, edit $TEXMF/dvips/config/config.ps and comment out the line
o |lpr
If you want to add unsupported papersize to dvips, for instance a5, add the following lines to $TEXMF/dvips/config/config.ps:
@ a5 148.5mm 209.9mm
@+ ! %%DocumentPaperSizes: a5
@+ %%BeginPaperSize: a5
@+ a5
@+ %%EndPaperSize
Just remember that this makes you document not portable (for compilation, not viewing) to systems which do not have this definition in their config.ps.
The main problem with the mouse is that gpm(8) (text console mouse
driver) and
I used the following setup for my mouse (A4 Tech three button mouse, with wheel). For other mice you might need to choose different mouse type for gpm. See man 8 gpm.
repeat_type=raw
type=imps2
append=" -2 "
Option "Buttons" "5"
Option "Protocol" "IMPS/2"
Option "Device" "/dev/gpmdata"
Option "ZAxisMapping" "4 5"
Option "Emulate3Buttons" "yes"
Build kernel with appropriate driver included. If you choose it to be built as a module, then add to /etc/modules.conf (in Debian, edit files in /etc/modutils and run update-modules(8)), assuming the name of the driver for your sound card is emu10k1 (see /lib/modules/2.4.XX/kernel/drivers/sound):
alias sound-slot-0 emu10k1
You may also need to add (for the mixer):
alias sound-service-0-0 emu10k1
If you build the driver as a module, add to /etc/modules.conf (in Debian, edit files in /etc/modutils and run update-modules(8)), assuming that the name of the driver is ne (see /lib/modules/2.4.XX/kernel/drivers/net):
alias eth0 ne
You may also need to add the following for (ISA) cards:
options ne io=0xXXX irq=XX