You can use DECwindows as it comes packaged, or you can create a personalized environment. Most Motif applications provide built-in ways to change various settings such as colors and fonts. Customization functions are often found on the Options Menu on an application's menu bar. The customization features provided by an application typically are sufficient for most users. The changes you make with an application's option menu are recorded in special resource files.
You can modify these special files to further customize your environment; for example, you can change:
This chapter introduces the basics you need to customize your windows
environment by editing the
.Xdefaults
, Mwm
, .mwmrc
, and application-specific resource files.
It also describes
how to switch keyboard styles, in
Section 9.3.
After working through this chapter, you may want to learn more about
the things you can customize. Refer to the appendixes to this guide, the mwm
(1) and X
(1) reference pages, the MWM section of the
OSF/Motif Programmer's Guide,
the
X Window System Environment
manual, and the
X Window System Administrator's Guide.
An important feature of the X Window System is its flexibility. You can control many aspects of an application's look and feel by using a variable called a resource. You change the behavior or appearance of a program by changing the value associated with a resource variable.
A resource is typically named for the aspect of window appearance or
behavior that it controls. For example, the resource name iconBoxTitle
is the title displayed at the top of the icon box. Resources can be
set for data such as window size and color, graphics contents, and fonts.
The resources for each client are listed on its reference page.
Resources and values are recorded in special files called resource files. Most applications read these files during startup and use the entries you defined to customize the appearance and characteristics of their windows.
The system default resource values are specified in files in /usr/lib/X11/app-defaults
. These files are Mwm
, Xdefaults
, and application-specific resource files.
When you Save Current Settings with the Session Manager, you create
an .Xdefaults
file in your home directory. It differs from /usr/lib/X11/app-defaults/Xdefaults
insofar as you have customized
your session as discussed in
Chapter 7.
Note the prefix period
differentiating the names of your own .Xdefaults
file from the
system defaults file /usr/lib/X11/app-defaults/Xdefaults
.
When running Session Manager,
the values in the file /usr/lib/X11/app-defaults/Xdefaults
apply
to all applications and all users. Values in your ~/.Xdefaults
file affect all applications that you run. The values
in an application-specific resource file affect only a single application
that you run. The values in /usr/lib/X11/app-defaults/Xdefaults
apply only if you are running Session Manager (dxsession
). However,
the values in ~/.Xdefaults
apply regardless of which session
manager you use.
You can also use your .Xdefaults
file to customize individual
applications by adding to it specifications from application-specific resource
files. Another way to customize an individual application is by modifying,
in your home directory, a copy of its application-specific resource file.
.Xdefaults
File
If you select the Save Current
Settings menu item from the Session Manager's Options menu, an .Xdefaults
file is created in your home directory. You can also create one by
copying
/usr/lib/X11/app-defaults/Xdefaults
to ~/.Xdefaults
. You can modify, remove, or add to the
entries in it to customize your global windows environment.
See
Appendix D
for a sample .Xdefaults
file. Note that comment lines begin with an exclamation point (!).
The .Xdefaults
file is simply a list of resource specification
strings you enter or modify to customize your windows environment. Each
resource specification in an .Xdefaults
file has roughly the
following format.
(The exact format of a resource specification is given in Appendix A
of the X Window System Toolkit, P. Asente &
R. Swick, Digital Press, Bedford, MA, 1990.)
[name*]resource: value
Here,
name |
Specifies the name or name string
representing the application or window component to which the resource assignment
should apply. If this argument is not specified, the resource assignment
is globally available to all applications.
You must separate names in this string with either an asterisk (*) or a period (.), as follows:
|
resource | Specifies the resource (characteristic) you want to modify. |
value | Specifies the value that is to be assigned to the resource. |
Resource names are case sensitive. Most names begin with initial lowercase letters; compound names use initial capital letters to separate names, for example:
backgroundPixel
When you finish adding resource specifications to your .Xdefaults
file, you must load changes into the server to have them take effect.
To load
changes, take one of
the following actions:
.Xdefaults
file into the server.[Footnote 4]
Enter:
%
/usr/bin/X11/xrdb .Xdefaults
By contrast, you do not have to start a new session or run xrdb
to effect customizations contained in application-specific resource
filesyou merely restart the application.
There are two general ways to specify a color when you are customizing your environment:
To specify a color directly, that is, without using a color name, use a three-part hexadecimal number. The three parts of the number specify the intensity of red, green, and blue, respectively.
The number must begin with a number sign (#) and cannot include any spaces. Each of the three parts must use the same number of digits. Here are some examples:
#9047A5 #F0F #55559999BBBB #0000FF #50A070
When using a named color, be sure to type the name exactly as it appears
in the file /usr/lib/X11/rgb.txt
on your system. This list of
names is also available in
the color widget's Browser color model (see
Chapter 4).
Table 9-1 lists some of the window elements you can color. For more information, see the documentation for the client you want to modify.
There are many other ways to specify colors. See the X Window System Administrator's Guide.
To color this element | Use this resource |
Pointer foreground color |
DXsession.pointer_foreground:
|
Session Manager display foreground color |
DXsession.display_foreground:
|
Session Manager display background color |
DXsession.display_background:
|
xterm window text |
XTerm*foreground:
|
xterm window background |
XTerm*background:
|
xterm window text cursor |
XTerm*cursorColor:
|
xterm window mouse pointer |
XTerm*pointerColor:
|
Window frame text |
Mwm*foreground:
|
Window frame background |
Mwm*background:
|
Top and left window frame bevel |
Mwm*topShadowColor:
|
Bottom and right window frame bevel |
Mwm*bottomShadowColor:
|
Active window frame text |
Mwm*activeForeground:
|
Active window frame background |
Mwm*activeBackground:
|
Top and left active window beveling |
Mwm*topShadowColor:
|
Bottom and right active window beveling |
Mwm*bottomShadowColor:
|
Suppose you want all your xterm windows to have a blue background, a yellow foreground, and use the fixed font. Follow these steps:
.Xdefaults
file in
your home directory.
XTerm*foreground: yellow XTerm*background: blue XTerm*font: fixed
%
xrdb -merge .Xdefaults
Start a new terminal window by entering the following command in a terminal window:
%
xterm &
The new window's background should be blue and the foreground (text) should be yellow.
The default font sizes in DECterms are chosen to look best when using
100 DPI fonts. If the default fonts are too small or you are using 75 DPI
fonts, you can change the fonts by adding the following
resource specifications to the
DECterm resource file /usr/lib/X11/app-defaults/DXterm
or the
.Xdefaults
file in your home directory:
\s-1DXterm.main.terminal.bigFontSetName: -*-terminal-*-*-*--*-180-*-*-*-*-*-* DXterm.main.terminal.littleFontSetName: -*-terminal-*-*-*--*-140-*-*-*-*-*-*\s+1
Suppose you want to start a new terminal window, but want it to have
a red background. You can override the settings in your .Xdefaults
file by specifying colors on the command line. For example, enter
the following command:
%xterm -bg red &
Since you did not specify a foreground color (-fg
), the
yellow value was read from the .Xdefaults
file. To see which
options are actually available for a particular client, refer to an application's
reference page.
To specify a font on the command line, use the -fn
option. For example, the following command creates an xterm window using
an 18 point font named Courier:
%xterm -fn "-*-courier-medium-r-normal--18-*-*-*-*-*-*-*" &
The quotation marks surrounding the font name are necessary to prevent your shell from trying to interpret the wildcard font name as a file specification.
For a complete discussion of conventions for font names and font properties, see Part IV of the X Window System: The Complete Reference to Xlib, X Protocol, ICCM, XLFD. The X Window System Administrator's Guide provides detailed information about locating and managing fonts in the X Window System environment.
Keep the following in mind when customizing resource files:
dxsession
or dxterm
) in front of resource specifications
for other clients.
ifdef COLOR
construct to create an ~/.Xdefaults
file that supports both color and monochrome monitors. If you do not,
colors might be adjusted for monochrome in a way that results in blank displays.
Resources are assigned when the application program creates a window component or by the application's default resource file. Some applications define unique resources for window components. For example:
PrintCommand
resource in Mail
windowManagerName_default
, create_terminal
,
and applications
resources in the Session Manager
terminalMode
resource in DECterm
These resources are named in the individual applications' reference pages and default resource files located in:
/usr/lib/X11/app-defaults/
application-name
Customize these resources by referencing them by name in your .Xdefaults
file.
Example 9-1 and Example 9-2 show sample application default-resource files.
*dxdiff*textdisplay*fontList: fixed *dxdiff*displayLineNumbers: True *dxdiff*drawDiffsAsLines: False *dxdiff*displaymenu*borderWidth: 1
DXterm*terminalMode: 1 DXterm*autoWrapEnable: on DXterm*autoResizeTerminal: on DXterm*autoResizeWindow: on
You can use the .Xdefaults
file in
your home directory to add resource specifications that change the way keys
are mapped to text editing commands.
Table 9-2
lists the
text editing keys you can redefine and describes the preset text editing
function for each key.
Key | Editing Function |
-> (right arrow) | Moves the cursor one character to the right. In a single-line field, the cursor does not move when positioned at the end of the line. In a multiline field, the cursor moves into the first position of the next line. |
<- (left arrow) | Moves the cursor one character to the left. In a single-line field, the cursor does not move when positioned at the beginning of the line. In a multiline field, the cursor moves into the last position of the previous line. |
(up arrow) | In a multiline field, moves the cursor up one line. |
(down arrow) | In a multiline field, moves the cursor down one line. |
F12 | Positions the cursor at the beginning of the line. |
Shift/F12 | Positions the cursor at the end of the line |
F13 | Deletes characters to the left of the cursor through the beginning of the word, and shifts to the left all text to the right of the deleted characters. |
Shift/F13 | Deletes the characters to the right of the cursor through the beginning of the word, and shifts to the left all text to the right of the deleted character. |
<X]
(Delete key)
|
Deletes the character before the cursor and shifts to the left all text to the right of the deleted character. |
Shift/<X]
|
In overstrike mode, deletes the character under the cursor and shifts to the left all text to the right of the deleted character. |
A translation specification string in your .Xdefaults
file
assigns a text editing command to a named key or mouse button combination.
To assign a new editing command to a named key, use the following syntax:
*Text.translations:
key
:
function
Here,
key | Specifies the key or mouse button that is used to invoke the named function. |
function | Specifies the function to be invoked when the named key is pressed. |
You can also specify the following mouse buttons in a translation specification string:
Btn1 | Left button |
Btn2 | Middle button |
Btn3 | Right button |
You can assign the following actions to each mouse button:
Down | Action is invoked when the button is pressed. |
Up | Action is invoked when the button is released. |
PtrMoved | Action is invoked when the mouse button is down and the pointer is moved. |
Example 9-3
provides text translation entries you can add to your .Xdefaults
file. These resource specifications assign emacs
-like key bindings
to your keyboard keys when you use the Motif text widget (as, for example,
when you edit with the Notepad [dxnotepad
] desktop application).
*Text.translations: ! Shift<Key>osfDelete: delete-next-character()\n\ <Key>osfDelete: delete-previous-character()\n\ Shift<Key>osfRight: forward-word()\n\ Shift<Key>osfLeft: backward-word()\n\ <Key>F12: beginning-of-line()\n\ Shift<Key>F13: delete-next-word()\n\ <Key>F13: delete-previous-word()\n\ Ctrl<Key>e: end-of-line()\n\ Ctrl<Key>j: delete-previous-word()\n\ Ctrl<Key>h: beginning-of-line()\n\ Ctrl<Key>r: redraw-display()\n\ Ctrl<Key>u: delete-to-start-of-line()\n\ ! ! ! Shift ~Ctrl ~Alt<Btn1Down>: extend-start()\n\ Shift ~Ctrl ~Alt Button1<PtrMoved>: extend-adjust()\n\ Shift ~Ctrl ~Alt<Btn1Up>: extend-end()\n\ Ctrl ~Shift ~Alt<Btn1Down>: grab-focus() set-insertion-point()\n\ Ctrl ~Shift ~Alt Button1<PtrMoved>: \n\ Ctrl ~Shift ~Alt<Btn1Up>: \n\ ~Shift ~Ctrl ~Alt Button1<PtrMoved>: extend-adjust()\n\ ~Shift ~Ctrl ~Alt<Btn1Up>: extend-end()\n\ ~Shift ~Ctrl ~Alt<Btn3Down>: stuff()\n\ ! ! ! Ctrl<Key>f: forward-character()\n\ Ctrl<Key>b: backward-character()\n\ Alt<Key>f: forward-word()\n\ Alt<Key>b: backward-word()\n\ Alt<Key>]: forward-paragraph()\n\ Ctrl<Key>[: backward-paragraph()\n\ Ctrl<Key>a: beginning-of-line()\n\ Ctrl<Key>e: end-of-line()\n\ Ctrl<Key>n: next-line()\n\ Ctrl<Key>p: previous-line()\n\ Ctrl<Key>v: next-page()\n\ Alt<Key>v: previous-page()\n\ Alt<Key>\\<: beginning-of-file()\n\ Alt<Key>\\>: end-of-file()\n\ Ctrl<Key>z: scroll-one-line-up()\n\ Alt<Key>z: scroll-one-line-down()\n\ Ctrl<Key>d: delete-next-character()\n\ Ctrl<Key>h: delete-previous-character()\n\ ~Shift Alt<Key>d: delete-next-word()\n\ ~Shift Alt<Key>h: delete-previous-word()\n\ Ctrl<Key>w: kill-selection()\n\ Ctrl<Key>y: unkill()\n\ Alt<Key>y: stuff()\n\ Ctrl<Key>j: newline-and-indent()\n\ Ctrl<Key>o: newline-and-backup()\n\ Ctrl<Key>m: newline()\n\ Ctrl<Key>l: redraw-display()\n\ Ctrl<Key>k: kill-to-end-of-line()\n\ Any<Key>: self-insert()
Table 9-3 summarizes the functions you can assign to keys and describes the text-editing action for each.
Function | Description |
forward-character
|
Moves the cursor forward one character. |
backward-character
|
Moves the cursor backward one character. |
forward-word
|
Moves the cursor forward one word. |
backward-word
|
Moves the cursor backward one word. |
forward-paragraph
|
Moves the cursor forward one paragraph. |
backward-paragraph
|
Move backward one paragraph. |
delete-next-character
|
Deletes the character after the insertion point. |
delete-previous-character
|
Deletes the character before the insertion point. |
delete-next-word
|
Deletes the word after the insertion point. |
delete-previous-word
|
Deletes the word before the insertion point. |
delete-next-line
|
Deletes the line after the insertion point. |
delete-previous-line
|
Deletes the line before the insertion point. |
delete-selection
|
Deletes the selection. |
insert-file
|
Inserts a file into the text. |
kill-next-word
|
Kills the word after the insertion point. |
kill-to-end-of-line
|
Kills the characters after the insertion point to the end of the line. |
kill-selection
|
Kills the selection. |
newline-and-indent
|
Moves the cursor to the next new line and indent. |
newline-and-backup
|
Moves the cursor to the beginning of the previous line. |
next-page
|
Moves the cursor to the next screenful of text. |
previous-page
|
Moves the cursor to the previous screenful of text. |
select-all
|
Selects all the text. |
select-word
|
Selects the word the insertion point is in. |
stuff
|
Inserts the text that was last selected in any window. |
unkill
|
Inserts the text that was last deleted. |
Several Digital workstations come with Personal Computer (PC) style keyboards. Currently, these keyboards have one of the following model numbers, although more models may be produced in the future:
Other Digital workstations come with keyboards such as the LK201 or LK401.
The two styles of keyboards differ both in the functions assigned to certain keys and in the number of function keys. For example, the PC-style keyboards have only 12 function keys (F1 through F12); the LK201/LK401 keyboards have 20 function keys (F1 through F14, Help, Do, and F17 through F20).
DIGITAL UNIX
provides a script that automatically performs mappings to
allow you to switch keyboard styles. This script, /usr/examples/pc_to_lk_keys.sh
, uses the xmodmap
utility to edit the keyboard modifier
map and keysym
table. (For details about the utility, see the
xmodmap
(1X) reference page.)
If you have a PC-style keyboard, you can run the script to map most of the keys on the two keypads to the right of the main keyboard, as well as a few keys in the top function key row, to the corresponding keys on the LK201/LK401 keyboards. For example, by running the script, you change the function of the keypad Insert key on the PC-style keyboard to perform the keypad Find function from the LK201/LK401 keyboards.
Similarly, if you have an LK201/LK401 style keyboard, you can run the
same script, this time with the -u
option flag, to map the
keypad keys to the corresponding PC-style keys.
A copy of the script is located in the following file on your
DIGITAL UNIX
system: /usr/examples/pc_to_lk_keys.sh
To run the script, at the system prompt enter the name of the file as if you were entering a command. The first command line in the following example changes PC-style keys to LK201/LK401 keys. The second command line changes LK201/LK401 keys to PC-style keys.
% /usr/examples/pc_to_lk_keys.sh % /usr/examples/pc_to_lk_keys.sh -u
To have the script run automatically each time you log on to your workstation,
use an editor to create or modify the .xsession
file in your
home directory to read as follows
:
#!/bin/sh /usr/examples/pc_to_lk_keys.sh dxsession
This change PC-style keys to LK201/LK401 keys.
The same .xsession
file, but with -u
added to the
end of the second line, changes LK201/LK401 keys to PC-style keys.
Now, whenever you log in, your keyboard is automatically set to the different keyboard style.
Table 9-4 shows the keys on the LK201/LK401 keyboard and their corresponding equivalents on the Digital PC-style keyboard.
Key on the LK201/LK401 Keyboards | Equivalent Key or Function on a PC-Style Keyboard |
Help | Print Screen |
Do/Menu | Scroll Lock |
Insert | Home |
Find | Insert |
Remove | Page Up |
Next | Page Down |
Select | Delete |
Prev | End |
Keypad 0 | Ins, Keypad 0 |
Keypad 1 | End, Keypad 1 |
Keypad 2 | down arrow, Keypad 2 |
Keypad 3 | PgDn, Keypad 3 |
Keypad 4 | left arrow, Keypad 4 |
Keypad 5 | Keypad 5 |
Keypad 6 | right arrow, Keypad 6 |
Keypad 7 | home, Keypad 7 |
Keypad 8 | up arrow, Keypad 8 |
Keypad 9 | PgUp, Keypad 9 |
Keypad . (period) | Keypad Del |
Keypad - | Keypad + (addition) |
Keypad , | no equivalent PC-style keypad key |
Keypad Enter | Keypad Enter |
PF1 | Num Lock |
PF2 | Keypad / (division) |
PF3 | Keypad * (multiplication) |
PF4 | Keypad - (subtraction) |
Note that the Digital PC-style keyboard has a key labeled <- in
the position where the key marked
<X]
is located on the LK201/LK401 keyboard. On both styles of
keyboard, this key deletes the character to the left of the cursor when pressed.
On the PC-style keyboard, you can use the
Delete key on the near keypad to delete the character that
the block cursor is on or the character to the left of the line cursor.
In keyboard mappings, the <- and
<X]
keys perform the backspace function. The Delete key on the
PC-style keyboards performs the delete function.
To customize the Motif window manager (mwm), modify a special
file called .mwmrc
or set resources in the Mwm
file in your home directory.
The Mwm
file contains resource settings for window manager
items such as border, menu, and icon colors; focus policy; use of an icon
box; icon placement and size; and menu bindings. The mwm first searches your
home directory for the Mwm
file, then searches for it in /usr/lib/X11/app-defaults
.
Place all mwm resources in the Mwm
resource file. For new
resources to take effect, select Restart from the Workspace menu to restart
mwm.
Tip
For monochrome monitors, mwm overrides the color resources defined in Mwm
with those defined in /usr/lib/X11/app-defaults/Mwm_bw
and /usr/lib/X11/app-defaults/Mwm_gray
.
Default operation of mwm is controlled by the systemwide file named /usr/lib/X11/system.mwmrc
. This file establishes the contents of the
Workspace (root) and Window menus, and what key and button combinations you
use to invoke menu functions and manage windows.
The file .mwmrc
defines:
See Appendix D for a listing of specific appearance and behaviors you can change.
This section describes how
to make a personal copy of .mwmrc
to add a Workspace submenu
called "Clients" that contains some of the more frequently used
X Consortium clients.
Appendix D
contains a sample file
you can use for a reference.
system.mwmrc
to your home directory with
the following command:
%
cp /usr/lib/X11/system.mwmrc .mwmrc
.mwmrc
file. Look for the following text:
Menu RootMenu { "Workspace" f.title "Shuffle Up" _U f.circle_up "Shuffle Down" _D f.circle_down "Next Window" _N f.next_key "Previous Window" _v f.prev_key no-label f.separator "Pack Icons" _P f.pack_icons "Options" _O f.menu MwmCustomizeMenu no-label f.separator "Restart..." _R f.restart "Help" _H f.menu MwmHelpMenu }
After the line that begins with "Help"
(and before the close
brace), insert the following line to add a menu item called Clients to your
Workspace menu:
"Clients" _C f.menu MyClientsMenu
After the close brace, enter the following text to create the new Clients
menu. Note the f.exec
function is used to call each client.
Menu MyClientsMenu { "Clients Menu" f.title "Start Clock" f.exec "xclock &" "Start Load" f.exec "xload &" "Start Calc" f.exec "xcalc &" "Start xbiff" f.exec "xbiff &" }
When you are done, double-check your typing and then save the file.
The changes you made to .mwmrc
are not read by the window
manager until it is restarted. Select the Restart menu item in the Workspace
menu to restart the window manager.