Startx with the Motif Window Manager (Lesstif)

Using the Motif (Lesstif Window Manager)

To determine the client to run, "startx" first looks for a file called ".xinitrc" in the /root directory. If that is not found, it uses the file "xinitrc" in the "xinit" library directory (/etc/X11/xinit/xinitrc). If command line client options are given, they override this behavior. To determine the server to run, "startx" first looks for a file called ".xserverrc" in the user's home directory. If that is not found, it uses the file "xserverrc" in the "xinit" library directory. If command-line server options are given, they override this behavior and revert to the xinit behavior.

User's rarely need to provide a ".xserverrc" file. The system-wide "xinitrc" and "xserverrc" files are found im the "/usr/X11R6/lib/X11/xinit" directory.

The ".xinitrc" is typically a shell script which starts many clients according to the user's preference.

Bla, Bla, Bla. The best way is as follows: When installing your Slackware in expert mode get off with the KDE (K Desktop Environment) in the KDE section and all window managers in the set xap i.e. Blackbox, Fluxbox, WindowMaker, FVWM, XFce, etc; then when you arrive at the prompt asking you to select from a list of installed window managers, a window manager by default, click on cancel, don't worry, the installation will continue normally; you'll notice that the Motif (Lesstif), don't appear among these window managers. When you get finish with the installation (In the menu, select "quit", when the bash appear just do "Ctrl-Alt-Del", your cdrom will get ejected (take it), tik "Enter", and your system will reboot; now the first thing to do, is login as "root", put your "root password", and adding a user (You), with the "adduser" command, you only need to complete your new login, new password, and the end, push to Enter to continue to complete your new login with your Full Name, etc. Now you still "root", go to "/usr/X11R6/lib/X11/xinit/", open your Emacs editor (Vi, Vim, XEmacs, Jed, Joe, Jove, etc.), with the "Ctrl-x d",then "Enter" you'll see the "xinitrc.twm" script, save it as xinitrc, now open this xinitrc script (it's already open is you are using XEmacs editor), and where you see: /usr/X11R6/bin/twm & etc. replace it with only this line: "exec /usr/X11R6/bin/mwm" and save it! Then go to "/usr/X11R6/lib/X11/mwm/" open the script system.mwmrc ("/usr/X11R6/lib/X11/mwm/system.mwmrc"), with your editor and save it in your directory /home/foo under the name: ".mwmrc" ("/home/foo/.mwmrc").

I insist to do this way to get off with links between the xinitrc.twm and the xinitrc; when you don't select any window manager by default, you get no xinitrc at the /usr/X11R6/lib/X11/xinit/ directory; and no .xinitrc in your /root directory; with this method you don't need it; you only have the xinitrc.twm without links. The easiest way to get a xinitrc script, is saving the xinitrc.twm under xinitrc; this way, you still have the xinitrc.twm for the TWM (you still having this window manager in your system too!). You could try TWM, this window manager is shipped with your XFree86's tarball (your X Window System), is a very basic window manager.

Now you can go to the script Mwm at "/usr/X11R6/lib/X11/app-defaults/Mwm", open it whith your Emacs editor (Vi, Vim, XEmacs, Jed, Joe, Jove, etc.), and where you get "!*usePager False" put instead "*usePager True" save it; so, you will have a useful tool to switch between your virtual desktops. (there are 6 by default)

Don't forget this: when you are using the Motif window manager, make sure your "Num Lock" light (lighting), on your keyboard is off, otherwise most of the motif commands will not work. i.e. You want to reduce the groot of your gftp window and if you try with a click on the cornerwith your mouse, nothing will happen!

Now, if you are using like me Slackware Linux, your Motif window will normally work.

If you want to use more than one window managers i.e. Motif, TWM, and KDE; you'll need a selector manager to replace the kdm (from KDE), gdm (from GNOME, not included in the Slackware distribution) or the xdm (shipped with the XFree86, extremely basi...); if you don't want to install KDE, or use his kdm, try the Selectwm, exit from "root" mode, and with your Links browser go to http://www.ordiluc.net/selectwm/, and get the selectwm version 0.4.1 in your home directory ("/home/foo"); become "root" again, and install it in yourr "/usr/local" directory.

Selectwm will not find the KDE, when you rightclick on the selectwm, you must fill the path to KDE yourself; with Slackware the path is: /opt/kde/bin/startkde

Another way if you don't want to use selectwm, is using startx for the Motif window manager, and keep the kdm to use KDE and TWM

Don't use the Motif with your kdm, even if the Motif is already there, it will not work! And you will not be able to exit from Motif in a clean way. First do the necessary als indicated above; and then, you can go to Motif, with your kdm selector.

If you have selected a window manager by default go to the "/root/" directory and look for the .xinitrc script (use the command: "ls -all") and, where you read:"#start some nice programs" followed by: "/usr/X11R6/bin/twm" etc, etc. just put "exec /usr/X11R6/bin/mwm" (don't put the "&"), save it (don't forget here the period: "." ahead of xinitrc); do the same thing with the script xinitrc at: "/usr/X11R6/lib/X11/xinit/" (no heading period here). Then go to "/usr/X11R6/lib/X11/mwm/system.mwmrc" open the script system.mwmrc with your editor and save it under the name:".mwmrc", in your directory "/home/foo" as /home/foo/.mwmrc

When this shell script exits, "startx" kills the server and performs any other session shutdown needed. Most of the clients started by ".xinitrc" should be run in the foreground; when it exits, the session will exit.

People often choose a session manager, window manager, or "xterm" as the "magic" client.

Here, I will not insist to add clients on the xinitrc script; I rather prefer to hold all the stuff for the .Xresources file in the home directory, to prevent futurs interactions with others window managers installed. Actually I never use the .Xresource file anyway.

Environment Variables

DISPLAY

This variable gets set to the name of the display to which clients should connect. Note that this gets "set", not read.

XAUTHORITY (/home/foo/.Xauthority)

This variable, if not already defined, gets set to "$HOME/.Xauthority".

This is to prevent the X server, if not given the "-auth" argument, from automatically setting up insecure host-based authentication for the local host. (Replace foo with the name your home directory have).

Files

"/root/.xinitrc"

Client to run. Typically a shell script which runs many programs in the background.

"$HOME/.xserverrc" (not for us actually)

Server to run. The default is X.

"/etc/X11/xinit/xinitrc"

Client to run if the user has no ".xinitrc" file.

"/usr/X11R6/lib/X11/xinit/xinitrc"

Client to run if the user has no ".xinitrc" file. (We are not deal with this here now)

"/usr/X11R6/lib/X11/xinit/xserverrc"

server to run if the user has no ".xserverrc" file (Not for us actually)

If you use a graphical login manager as xdm, gdm or kdm you will need to modifie a script called .Xsession, but here we are going to talk about dealing with startx, and you could also install select manager, if you got several window managers; dus nor .Xsession, neither .Xdefault here.

"foo" is your username for your home (like peter, tom, etc.)

Now you downloaded selectwm-0.4.1.tar.gz, you must to install it at /usr/local directory, and once the installation is finished; you must change some data in the .xinitrc script, which you can find at /root directory (.Xsession if you are going to use a graphical login manager like xdm), with ypour preferred teext-editor like Emacs (for exemple)>

Look for a section that seems something like:

# start some nice programs
twm &
xclock -geometry 50x50-1+1 &
xterm -geometry 80x50+494+51 &
xterm -geometry 80x20+494-0 &
exec xterm -geometry 80x66x+0+0 -name login
Change the lines below # with:
exec /usr/local/bin/selectwm and save the modifications.

Ofwell, if you are using the .Xsession (with a graphical login manager):

# Start windowmanager
which "$wm" && exec "$wm"

Now you can start your X system with the command: "startx", ofwell if your X window is already started, restart the x server.

If you don't have any xinitrc or Xsession files, that is possible that your x server uses the xinitrc or xsession files located in the repertory /etc/X11/xinit/. Modifie theses scripts the same way.

Modifying default behaviours with the .mwmrc file

As delivered, the Motif Window Manager (mwm) does not provide a much-needed and almost standard action: clicking on the title bar of a rear window brings it to the front instead, this action, called "raising" the window, requires that you hold down the Meta key and click Button1 on the title bar. The meta key is on the keyboard, is represented by the key with a small diamond on the keymap. This key is located next to the spaces bar (nowadays it is called: Alt key).

You may change the default bahavior of the mouse buttons and keyboards keys through the .mwmrc file. This file can be found in your home directory after running xjump if your account has been set up to use motif as its user interface.

system.mwmrc Vocabulary

LessTif Vocabulary

The .mwmrc (.Xresource file)

The .mwmrc (.Xresource file)

LessTif Vocabulary

MWMRC

NAME

mwmrc -The Motif Window Manager configuration file

DESCRIPTION

The Lesstif window manager mwm supports both a global configuration file /etc/X11R6/lib/X11/mwm/system.mwmrc and a per-user configuration file /home/foo/.mwmrc

STRUCTURE

Each mwm configuration file consist of blocks of bindings. Each block consist of a block type keyword, a menu and a set of entries between curly braces ("{" and "}").

An exclamation mark ("!") introduces a comment. Comments extend to the end of the line.

Block types

There are three types of blocks:

Menu bindings
Button bindings
Key bindings

Menu bindings

Menu bindings are introduced by the Menu keyboard. The generic form of the entries is "label mneumonic accelerator function".

Both "mneumonic" and "accelerator" may be empty. for example:

"Foo bar" _R Alt<Key>F5 f.restore

Button bindings

Button bindings are introduced by the Buttons keyword. The entries each are "Button name Content Function". For example:

<Bt3Down> icon|frame f.post_wmenu

Key bindings

Key bindings are very similar to button bindings. The entries each are "Key name Context Function". For example:

<Key> root|icon|window f.next_key

Label

A label is either a plain string, or a bitmap. Bitmaps are indicated as "@" followed by the filename. For example:

_M

Accelerator

An accelerator is a key name.

Button name

A button name is Btn followed by the number (1 to 5) and an action (Up, Down, Click, Click2); for example:

Btn2Click

Context

A context is a single string consisting of bar ("|") separated object names (root, icon, menub, minimizeb, maximizeb, window, title, frame, border); for example:

icon|title

Function

A function is a string starting with "f.". The functions are:

f.beep
f.circle_down
f.circle_up
f.desk
f.exec
f.focus_color
f.focus_key
f.goto_page
f.kill
f.lower
f.maximize
f.menu
f.minimize
f.move
f.next_cmap
f.next_key
f.nop
f.normalize
f.normalize_and_raize
f.pack_icons
f.pass_keys
f.post_wmenu
f.prev_key
f.quit_mwm
f.raise
f.raise_lower
f.refresh
f.refresh_win
f.resize
f.restart
f.restore
f.restore_and_raise
f.screen
f.send_msg
f.separator
f.set_behavior
f.title
f.toggle_page
f.window_list

In the .mwmrc (original Slackware 10.2), note that Alt is in fact the Meta key. Please remember that.

Among others, the .mwmrc file contains the following lines:

#
# Button Binding Descriptions
#

Buttons DefaultButtonBindings
{
      <Btn1Down>             root            f.menu RootMenu
      <Btn2Down>             root            f.menu RootMenu
      <Btn3Down>             root            f.menu RootMenu
  Meta<Btn1Down>             root            f.menu RootMenu
  Meta<Btn2Down>             root            f.menu RootMenu
  Meta<Btn3Down>             root            f.menu RootMenu
  Meta<Btn1Down>           window            f.raise
  Meta<Btn1Down>             icon            f.maximise
  Meta<Btn3Down>       window|icon         f.move
}

The first column specifies the combination of keyboard, keys and mouse buttons. The second column specifies the location on the screen where the action takes place. And the third column specifies the appropriate action to take.

For example, the first line:

<Btn1Down>   root   f.menu RootMenu

means "if Button 1 is pressed on the root window (the background), the RootMenu is displayed.

To make MWM automatically raise a rear window when clicked on its title bar, add the following line:

<Btn1Down>   window    f.raise

The xinitrc script

Here below a standard xinitrc script,xinitrc.twm with TWM as window manager. After much testing several ways, I have to admit that the best way to running window managers, is using the .mwmrc script in your personal home directory (a .Xresource script)

If you are using Slackware, then when you will be asked for a window manager during the install process, if you know what you are doing select Twm, here below a sample with a xinitrc using twm as window manager:

#!/bin/sh
# $Xorg: xinitrc.cpp,v 1.3 2000/08/17 19:54:30 cpqbld Exp $

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/usr/X11R6/lib/X11/xinit/.Xresources
sysmodmap=/usr/X11R6/lib/X11/xinit/.Xmodmap

# merge in defaults and keymaps

if [ -f $sysresources ]; then
    xrdb -merge $sysresources
fi

if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap
fi

if [ -f $userresources ]; then
    xrdb -merge $userresources
fi

if [ -f $usermodmap ]; then
    xmodmap $usermodmap
fi

# start some nice programs

twm &
xclock -geometry 50x50-1+1 &
xterm -geometry 80x50+494+51 &
xterm -geometry 80x20+494-0 &
exec xterm -geometry 80x66+0+0 -name login

The Mwm script (applications default script)

Another original script (Slackware 10.2) called Mwm Mwm needed to customise your applications is this script:

!! $Id: Mwm.ad,v 1.1 2004/08/28 19:29:29 dannybackx Exp $
!!
!! app defaults for mwm
!!
!! When reading the resources, the uncommented ones work, the commented ones
!! either don't work, or you probably don't want to set values for them here
!! as their default value depends on other resources (focusAutoRaise, for
!! example, depends on the keyboardFocusPolicy.  At the bottom of this file,
!! you will find some resources that I've customized to demonstrate behaviors.
!! With all resources, I've tried to be faithful to what Mwm does, but if
!! you find a particular hole, please let me know.
!!

!!
!! fonts for everone
!!
*fontList:		variable

!!
!! The following resources have been implemented, and can be altered.
!!
*autoKeyFocus:		True
*autoRaiseDelay:	500
*bitmapDirectory:	/usr/include/X11/bitmaps
*buttonBindings:	DefaultButtonBindings
*cleanText:		True
*clickTime:		100
*clientAutoPlace:	True
*colormapFocusPolicy:	keyboard
*configFile:		~/.mwmrc
*deiconifyKeyFocus:	True
!*doubleClickTime:	"varies"
!*edgeScrollX:		0
!*edgeScrollY:		0
*frameBorderWidth:	5
*iconAutoPlace:		True
*iconClick:		True
*keyBindings:		DefaultKeyBindings
*keyboardFocusPolicy:	explicit
*lowerOnIconify:	True
*moveThreshold:		4
*multiScreen:		False
*quitTimeout:		1000
*resizeBorderWidth:	8
*resizeCursors:		True
*showFeedback:		all
*startupKeyFocus:	True
*transientDecorations:	menu title border
*transientFunctions:	-minimize -maximize
!*usePager:		False
!*smartPlacment:	True
*wMenuButtonClick:	True
*wMenuButtonClick2:	True

!!
!! not tracked yet.  Some are implemented, but you can't change the default
!! behavior.
!!
!*enableWarp:		True
!*enforceKeyFocus:	True
!*fadeNormalIcon:	False
!*feedbackGeometry:	"center on screen"
!*iconBoxGeometry:	6x1+0-0
!*iconBoxName:		iconbox
!*iconBoxSBDisplayPolicy:	all
!*iconBoxTitle:		Icons
!*iconDecoration:	"varies"
!*iconImageMaximimum:	50x50
!*iconImageMinimimum:	16x16
!*iconPlacement:	left bottom
!*iconPlacementMargin:	"varies"
!*interactivePlacement:	False
!*limitResize:		True
!*maximumMaximumSize:	"2 * screen_width x 2 * screen_height"
!*moveOpaque:		False
!*passButtons:		False
!*passSelectButtons:	True
!*positionIsFrame:	True
!*positionOnScreen:	True
!*screens:		"varies"
!*useIconBox:		False

!!
!! component appearance resources.  We go farther than Motif in that you
!! can specify values for all Mwm components.  Not all are implemented,
!! though (why would a menu button want a font?).
!!
*menu.background:		rgb:72/9f/ff
!*menu.backgroundPixmap:	"varies"
!*menu.bottomShadowColor:	"varies"
!*menu.bottomShadowPixmap:	"varies"
*menu.fontList:			variable
*menu.foreground:		Black
*menu.saveUnder:		True
!*menu.topShadowColor:		"varies"
!*menu.topShadowPixmap:		"varies"

*feedback.background:		Cadet Blue
!*feedback.backgroundPixmap:	"varies"
!*feedback.bottomShadowColor:	"varies"
!*feedback.bottomShadowPixmap:	"varies"
*feedback.fontList:		variable
*feedback.foreground:		Black
*feedback.saveUnder:		True
!*feedback.topShadowColor:	"varies"
!*feedback.topShadowPixmap:	"varies"

*pager.background:		White
!*pager.backgroundPixmap:	"varies"
!*pager.bottomShadowColor:	"varies"
!*pager.bottomShadowPixmap:	"varies"
*pager.fontList:		fixed
*pager.foreground:		Black
*pager.saveUnder:		True
!*pager.topShadowColor:		"varies"
!*pager.topShadowPixmap:	"varies"

*icon.background:		LightGrey
!*icon.backgroundPixmap:	"varies"
!*icon.bottomShadowColor:	"varies"
!*icon.bottomShadowPixmap:	"varies"
*icon.fontList:			fixed
*icon.foreground:		Black
*icon.saveUnder:		True
!*icon.topShadowColor:		"varies"
!*icon.topShadowPixmap:		"varies"
*icon.activeBackground:		Cadet Blue
!*icon.activeBackgroundPixmap:	"varies"
!*icon.activeBottomShadowColor:	"varies"
!*icon.activeBottomShadowPixmap:"varies"
*icon.activeForeground:		Black
!*icon.activeTopShadowColor:	"varies"

*client*title.background:		LightGrey
!*client*title.backgroundPixmap:	"varies"
!*client*title.bottomShadowColor:	"varies"
!*client*title.bottomShadowPixmap:	"varies"
*client*title.fontList:			variable
*client*title.foreground:		Black
*client*title.saveUnder:		True
!*client*title.topShadowColor:		"varies"
*client*title.activeBackground:		Cadet Blue
!*client*title.activeBackgroundPixmap:	"varies"
!*client*title.activeBottomShadowColor:	"varies"
!*client*title.activeBottomShadowPixmap:"varies"
*client*title.activeForeground:		Black
!*client*title.activeTopShadowColor:	"varies"
!*client*title.activeTopShadowPixmap:	"varies"

*client*resizeh.background:		LightGrey
!*client*resizeh.backgroundPixmap:	"varies"
!*client*resizeh.bottomShadowColor:	"varies"
!*client*resizeh.bottomShadowPixmap:	"varies"
*client*resizeh.foreground:		Black
*client*resizeh.saveUnder:		True
!*client*resizeh.topShadowColor:	"varies"
*client*resizeh.activeBackground:	Cadet Blue
!*client*resizeh.activeBackgroundPixmap:	"varies"
!*client*resizeh.activeBottomShadowColor:	"varies"
!*client*resizeh.activeBottomShadowPixmap:	"varies"
*client*resizeh.activeForeground:		Black
!*client*resizeh.activeTopShadowColor:	"varies"
!*client*resizeh.activeTopShadowPixmap:	"varies"

*client*border.background:		LightGrey
!*client*border.backgroundPixmap:	"varies"
!*client*border.bottomShadowColor:	"varies"
!*client*border.bottomShadowPixmap:	"varies"
*client*border.foreground:		Black
*client*border.saveUnder:		True
!*client*border.topShadowColor:		"varies"
*client*border*activeBackground:	Cadet Blue
!*client*border.activeBackgroundPixmap:	"varies"
!*client*border.activeBottomShadowColor:	"varies"
!*client*border.activeBottomShadowPixmap:	"varies"
*client*border.activeForeground:		Black
!*client*border.activeTopShadowColor:	"varies"
!*client*border.activeTopShadowPixmap:	"varies"

*client*maximizeb.background:		LightGrey
!*client*maximizeb.backgroundPixmap:	"varies"
!*client*maximizeb.bottomShadowColor:	"varies"
!*client*maximizeb.bottomShadowPixmap:	"varies"
*client*maximizeb.foreground:		Black
*client*maximizeb.saveUnder:		True
!*client*maximizeb.topShadowColor:	"varies"
*client*maximizeb.activeBackground:	Cadet Blue
!*client*maximizeb.activeBackgroundPixmap:	"varies"
!*client*maximizeb.activeBottomShadowColor:	"varies"
!*client*maximizeb.activeBottomShadowPixmap:	"varies"
*client*maximizeb.activeForeground:		Black
!*client*maximizeb.activeTopShadowColor:	"varies"
!*client*maximizeb.activeTopShadowPixmap:	"varies"

*client*minimizeb.background:		LightGrey
!*client*minimizeb.backgroundPixmap:		"varies"
!*client*minimizeb.bottomShadowColor:	"varies"
!*client*minimizeb.bottomShadowPixmap:	"varies"
*client*minimizeb.foreground:		Black
*client*minimizeb.saveUnder:			True
!*client*minimizeb.topShadowColor:		"varies"
*client*minimizeb.activeBackground:		Cadet Blue
!*client*minimizeb.activeBackgroundPixmap:	"varies"
!*client*minimizeb.activeBottomShadowColor:	"varies"
!*client*minimizeb.activeBottomShadowPixmap:	"varies"
*client*minimizeb.activeForeground:		Black
!*client*minimizeb.activeTopShadowColor:	"varies"
!*client*minimizeb.activeTopShadowPixmap:	"varies"

*client*menub.background:		LightGrey
!*client*menub.backgroundPixmap:	"varies"
!*client*menub.bottomShadowColor:	"varies"
!*client*menub.bottomShadowPixmap:	"varies"
*client*menub.foreground:		Black
!*client*menub.saveUnder:		True
!*client*menub.topShadowColor:		"varies"
*client*menub.activeBackground:		Cadet Blue
!*client*menub.activeBackgroundPixmap:	"varies"
!*client*menub.activeBottomShadowColor:	"varies"
!*client*menub.activeBottomShadowPixmap:"varies"
*client*menub.activeForeground:		Black
!*client*menub.activeTopShadowColor:	"varies"
!*client*menub.activeTopShadowPixmap:	"varies"

!!
!! client resources implemented
!!
*.clientDecorations:			all
*.clientFunctions:			all
!*focusAutoRaise:			"varies"
!*iconImageBackground:			"varies"
!*iconImageBottomShadowColor:		"varies"
!*iconImageBottomShadowPixmap:		"varies"
!*iconImageForeground:			"varies"
!*iconImageTopShadowColor:		"varies"
!*iconImageTopShadowPixmap:		"varies"
*matteBackground:			Light Coral
!*matteBottomShadowColor:		"varies"
!*matteBottomShadowPixmap:		"varies"
*matteForeground:			Black
!*matteTopShadowColor:			"varies"
!*matteTopShadowPixmap:			"varies"
*.matteWidth:				0
*.windowMenu:				DefaultWindowMenu
*usePPosition:				nonzero
*useClientIcon:				False

!!
!! client resources that are either unimplemented or unchangeable.
!!
!*iconImage:				"varies"
!*maximumClientSize:			"screen size"

!!
!! Client decorations for common clients - SAMPLES
!!
*XClock.clientDecoration:		border
!*XLoad.clientDecoration:		border
!*XBiff.clientDecoration:		border

!!
!! uncomment these to see what they do.
!! some entertainment.  Can you tell I live in Florida?;)
!!
!*client*resizeh.activeBackground:	gold3
!*client*pager.background:		DarkTurquoise
!*client*pager.foreground:		Black
!*matteBackground:			Light Coral
!*matteWidth:				5

In these scripts each line beginning with thee sign ! is a commented line, dus be careful when you comment a line or uncomment another one; the best way to manage without problems is changing step by step, and trying only one thing at a time, and don't get in a hurry you have plenty of time to get your window manager working in your way

These two scripts slightly modified by me, you can get on my site are based on those ones; For me these scripts (the originals), are good, no matter some people will tell you about. The only thing is getting them customize at your way of dealing with the mouse, raising ans shadowing windows, the use of the buttoms, with or without the Meta (Alt) keys, etc. This will take you some time (no much) to get it right.

Copy Mwm to your app-defaults directory, again making any modifications that you prefer (note: not all resources do anything yet, so don't be surprised if you request something and it doesn't happen. All uncommented resources are working. those commented may work, or may yet require changes to libXm). If you have been using lesstif's mwm for sometime, I'd advise copying the latest one in. See comments in Mwm for details.

Changing the Menu Selections

To change the mouse popup menus, you need to edit your ".mwmrc" file. Both root and window menus are given in this file.

Each entry of the menu is given in the form of:

<menu_name>       f.exec          <command>

Where <menu_name> is the name that will show up in the menu, and <command> is the command used to execute the desired function. For example, to make a new entry in the Applications menu for vi, you would need to put the following line in the Applications menu section of .mwmrc:

"Vi"       f.exec "xterm -sb -T vi -e vi"

Note: the xterm is needed since vi needs a window to run.

or

"mozilla"  f.exec "mozilla &"

if you add an application which don't need a terminal to run.

To put a space in a menu, use the line:

no-label        f.separator

Changing the Colors of Tools

To change the colors of X tools (xterms, xclock, etc.) you need to edit the .Xdefaults file. This file give alll the color specificacions for the X tools, and menus. To change a color for a tool, find that tool in the file and change the default color to the color you desire. For example, to change XTerms to black background and white lettering, change the current line to:

XTerm*foreground:      white   #This changes the lettering color
XTerm*background:      black   #This changes the background color
XTerm*cursorColor:     white   #This changes the cursor's color
XTerm*pointerColor:    white   #This changes the mouse pointer color

Setting Resources

X programs can be customized by using resources. Thes resources can be specified in many different places. In order of increasing priority these include:

  1. Fallback resources programming into the application.
  2. Library resource files controlled with XFILESEARCHPATH variable.
  3. User resource files controlled with XUSERFILESEARCHPATH, and XAPPLRESDIR variables.
  4. X resource database, loaded with xrdb.
  5. X resource default files, $HOME/X.defaults or $HOME/.Xresources.
  6. Standard command line options.
  7. Hardcoded resources, set within the programs.

Options nearer the end of the list override ones further up the list. For personal customization of X programs, the best method to use is a single $HOME/.Xresources file ($HOME/.Xdefaults will probably also work, but is now obsolete). This file gets read when you start X. If you have a lot of resources to set for a particular program with a resource file, it would be searched when an X program is started. These two methods are discussed in more details below.

The .Xresources file

The simpliest and best way to customize X programs is to create a file called .Xresources in the top level of your home directoy.

Any line beginning with a ! is ignored, so can be used for comments. Each resource specification appears on a separate line and is often of the form:

Client*resource:  value

The client name is specified by the program, but unless stated otherwise, this is usually the name of the program with the first letter capitalized, e.g. mozilla becomes Mozilla, unless the first letter is an x, in which case the first two letters are capitalized, e.g. xterm becomes XTerm. the resource name is usually a single string, such as scrollBar. After the colon, and any whitespace, comes the value you wish to set the resource to. this is always a string, which gets converted into the correct type. So an example of a complete specification is:

XTerm*scrollBar: True

This would cause all xterms to have a scrollbar.

The resource field of the specification can actually be preceded by a path through the widget hierarchy.

In the specification XTerm.vt100.geometry: 80x25, the geometry resource is only specified for the vt100 widget of the xterm, which is the main text area.

If XTerm*geometry: 80x25 was used instead, all widgets, such as the menus which popup with Control-Mouse button conbinations, would be given the same geometry as the main text area. notice that in the first case, the fields were separated by '.", and not "*". This causes the widget you are setting the resource of to be specified exactly, whereas the "*" means "any routee through the widget hierarchy." Any combination for "." and "*" can be used in a resource specification.

The order of resource specifications in a file does not matter, as long as they do not conflict. If they do, a warning is usually given, and the one that appears last in the file is used. However the same resource can be specified twice if the generality of the specifications is different.

For example, Maker*background: gray70 would change the background colour of all widgets (unless overridden later) to be gray70. However, Maker*vertSB.background: gray65 could be used to change the background colour of all vertical scrollbars. Thus, the more specific resource is overriding the moe general one.

Another way of specifying widgets is to name a particular class. For example, Editres*Command.background: yellow would set all widgets of class commandWidgetClass, that is normal buttons, to have a yellow background.

Standard Options

Applications should document any specific resources that can be used with the program, but there are many standard options which can be used with virtually all X programs. These include:

display                -the X server to use
geometry               -the size and location
background, or bg      -background colour
bordercolor, or bd     -colour to use for borders
foreground, or fg      -foreground colour
font, or fn            -the font to use for displaying text
iconic                 -the program should be initially iconified
name                   -the name under which resources should be found
title                  -the title for the program window
xrm                    -specifies a resource name and value

A bit over geometry

To start a new tool on login:

<tool><tooloptions> -geometry <size><location> \&

Where <tool> can be anything supported by Motif, and <tooloptions> are the options supported by your specific tool. The geometry command specifies the size of the tool and the location on the workspace. The size is specified in pixels with a command like, 100x150 (width x length). The location on the workspace is given by a command like +0+414 (+xcoord + ycoord). This places the upper left corner of the window at location (0,414). The size of the entire workspace is 1135x868.

A way to find the size and location of a window is to use the xwininfo command. To do this, set up the window you want with the desired size and location in the workspace. Then, at a UNIX prompt type:

xwininfo

At the next prompt, click the mouse in the window you want to size. this will give a lot of information aboout the window, and the last line will be the -geometry line you should use for that tool to reproduce its size and location.

Some hints over Button Bindings

When you open with your Emacs editor or the Vi, the original system.mwmrc script, you will see at the top of it the Root Menu Description with his Menu DefaultRootMenu command (containing some commands options); below the Default Window Menu with his Menu DefaultWindowMenu (containing some command options); now a Default Key Bindings with his Keys DefaultKeyBindings (here you can change some behaviours); and finally the Button Binding Description title, with three sets of possible buttons bindings to choose: Buttons DefaultButtonBindings (uncommented), Buttons ExplicitButtonsBindings (commented), and Buttons PointerButtonBindings (commented).

You can change the "DefaultButtonBindings" to "ExplicitButtonBindings" to "DefaultButtonBindings"; I still believe that defaultButtonBindings in most cases remains the best choice. Must often, users just copy an mwmrc from someone else they know. You must take your own way instead it's a better option.

The other common thing you may want to change is the keyboard focus policy. This determines how you choose the window into which you will type. I prefer "click to focus" where a window keeps focus until you click in another window. This is the default Motif behaviour. the other option is: "focus follows mouse" which means that all I need to do is put the pointer into a window and I can start typing; which is the focus follows the mouse and it does not automatically raise the window with focus.

You can also set whether or not you want the window with focus to be raised automatically to the top of the stack. The two X resources you alter in your .Xdefaults file are:

Mwm*keyboardFocusPolicy:  pointer
Mwm*focusAutoRaise:       false

or

Mwm*keyboardFocusPolicy:  explicit
Mwm*focusAutoRaise:       true

"explicit" for keyboardFocusPolicy and "true" for focusAutoRaise.

In your .Xdefaults file, type: xrdb < .Xdefaults to update the settings, and finally restart mwm to apply the changes. Or simply restart your X system.

Arinwald
Last modified: Wed Mar 21 00:03:38 CET 2007