5. X starting up


When X starts up, xdm will execute a shell script typically found in /usr/lib/X11/xdm/Xsession. On the Silicon Graphics machines it looks like: ( Click here for an explanation of the codes)



    #!/bin/sh

    dim="`xdpyinfo | awk ' /dimensions/ {print $2}'`"

    if [ "$dim" = "1024x768" ]; then
        geom="80x40+190+102"
        font="-sgi-terminal-*-*-*--12-*"
    else
        geom="80x40+150+172"
        font="-sgi-terminal-*-*-*--17-*"
    fi

    case $# in
    1)
       case $1 in
       failsafe)
             exec xwsh -geom $geom -fn $font -xrm "XWsh*autoFork: off"
             ;;
       esac
    esac

    xsession  =$HOME/.xsession
    resources =$HOME/.Xresources
    sgisession=$HOME/.sgisession
    autoworkspace=$HOME/.workspace/autostart
    userenv=/usr/bin/X11/userenv

    if [ -r $xsession -a "$0" != $xsession ]; then
        if [ -x $xsession ]; then
             exec $xsession
        else
             exec /bin/sh $xsession
        fi
    fi

    if [ -r $resources ]; then
        xrdb -load -quiet $resources
    fi

    XUSERFILESEARCHPATH="$HOME/%N:`/usr/bin/X11/appdefpath`"
    export XUSERFILESEARCHPATH

    if [ -x $userenv ]; then
        #
        # Find user's environment as set up during a login
        # shell, and add that to current environment.
        #
        eval `$userenv`
    fi

    screens=`/usr/bin/X11/xlistscrns`

    for screen in $screens
        do
        /usr/bin/X11/xsetroot -solid sgilightblue -display $screen
        /usr/bin/X11/xsetroot -cursor_name X_cursor -fg red -bg white -display $screen 
        done

    # Gives anyone on any host access to this display
    /usr/bin/X11/xhost +

    # Note: Output from $HOME/.sgisession, 4Dwm, workspace
    # and toolchest is redirected to /dev/console.
    # All other output is written to
    # /usr/adm/SYSLOG by default.
    /usr/bin/X11/4Dwm >/dev/console 2>&1 &
    /usr/bin/X11/wait4wm

    /usr/sbin/startconsole -iconic

    if [ -x $sgisession ]; then
        $sgisession >/dev/console 2>&1 &
    elif [ -r $sgisession ]; then
        /bin/sh $sgisession >/dev/console 2>&1 &
    fi

    if [ -r $autoworkspace ]; then
        if [ "`cat $autoworkspace`" = "on" ]; then
             /usr/sbin/workspace >/dev/console 2>&1 &
        fi
    fi

    for screen in $screens
      do
      DISPLAY=$screen /usr/bin/X11/toolchest -name ToolChest >/dev/console 2>&1 &
      done

    exec /usr/bin/X11/reaper




On a raw X11R5 machine, it is more basic (it doesn't assume any specific Window manager such as Motif): ( Look in here for more explanation of the codes)



    #!/bin/sh

    exec > $HOME/.xsession-errors 2>&1

    case $# in
    1)
        case $1 in
        failsafe)
                exec xterm -geometry 80x24-0-0
                ;;
        esac
    esac

    startup  =$HOME/.xsession
    resources=$HOME/.Xresources

    if [ -f $startup ]; then
        exec $startup
    else
        if [ -f $resources ]; then
                xrdb -load $resources
        fi
        twm &
        exec xterm -geometry 80x24+10+10 -ls
    fi





A typical user ".xsession" file would then contain various commands to set up the X environment (similar to the above default setups). However, a user who has accounts on different systems may not want to run X the same on all machines especially different machines from different manufacturers! Therefore my ".xsession" file looks like this:



    #!/bin/csh

    if { 4d  } exec .indigo/.xsession
    if { sun } exec .sun/.xsession
    if { dec } exec .dec/.xsession
    if { ibm } exec .ibm/.xsession
    exec .xinitrc




The ".xsession" file in my area is as shown below and check out why I customize my environment as such.



    #!/bin/csh -f

    # set XENVIRONMENT: this resource file is read by each
    # application at startup.
    setenv XENVIRONMENT $HOME/.Xdefaults

    # Xlib looks at the value of XUSERFILESEARCHPATH to find
    # a dir of resource files
    setenv XUSERFILESEARCHPATH "$HOME/%N:`/usr/bin/X11/appdefpath`"

    xdpyinfo | awk ' /dimensions/ {print "setenv XSCREEN" $2 > ".xscreen" }'

    # source the file so that the variable is known to this
    # shell  and pause for the source to take place
    source .xscreen
    wait &

    # If the source failed, i.e. don't have permissions to
    # write to directory, etc., assume that you are on the
    # 1280x1024 size monitor and load the X resource data
    # base with that default file.
    # NOTE:  you could have one default file and test for
    # the resolutions there, instead of have 2 different
    # files as this .xsession file does. You still, have to
    # get the XSCREEN variable as you do here.
    if (!($?XSCREEN)) then
        xrdb -merge .Xdefaults_1280 &
    endif

    # If there is the XSCREEN variable, then make the seperate
    # tests for the dimensions and call the correct Xdefault file.

    if ($XSCREEN == '1024x768') then
        if (-f ~/.Xdefaults_1024) then
            xrdb -merge ~/.Xdefaults_1024 &
            setenv XUSERFILESEARCHPATH "$HOME/%N:`/usr/bin/X11/appdefpath`:$HOME/.app-defaults_1024/%N"
    # set XENVIRONMENT: this resource file is read by each
    # application at startup.
            setenv XENVIRONMENT $HOME/.indigo/.Xdefaults_1024
        endif
    endif

    if ($XSCREEN == '1280x1024') then
        if (-f ~/.Xdefaults_1280) then
            xrdb -merge ~/.Xdefaults_1280 &
            setenv XUSERFILESEARCHPATH "$HOME/%N:`/usr/bin/X11/appdefpath`:$HOME/.app-defaults_1280/%N"
    # set XENVIRONMENT: this resource file is read by each
    # application at startup.
            setenv XENVIRONMENT $HOME/.indigo/.Xdefaults_1280
        endif
    endif

    # If you display clients from remote machines back to your
    # own console you can uncomment the next line.
    #/usr/bin/X11/xhost +

    # start the window manager
    /usr/bin/X11/4Dwm&
    /usr/bin/X11/wait4wm

    # Test for screen dimensions then size the console window:
    # Now go ahead and start up the xwsh's depending on the
    # screen resolution of the machine we're currently on.
    # See XWSH(1G) for X-world command line options. "xwsh -help"
    # is a handy reminder of what options exist.
    #
    if ($XSCREEN == '1024x768') then
        xclock -geom 90x90+0+0 -analog -fn 12x24 -bd grey23 &
        xwsh -title `hostname` -geometry 80x40+287+20 -fn "*-lucidatypewriter-bold-*-*-*-*-8-100-100-*" -fg \
            54 -bg 98 -selbg 165 -selfg 9 -cursorfg 3 &
        setenv CONSOLE true
        xwsh -title console -icontitle console -geometry 80x40+0-2 -fn "*-lucidatypewriter-bold-*-*-*-*-8-100-100-*" \
            -fg 54 -bg 98 -selbg 165 -selfg 9 -cursorfg 3 &
    endif

    if ($XSCREEN == '1280x1024') then
        xclock -geom 90x90+0+0 -analog -fn 12x24 -bd grey23 &
        xwsh -title `hostname` -geometry 80x40+543+20 -fn "*-lucidatypewriter-bold-*-*-*-*-8-100-100-*" -fg \
            54 -bg 0 -selbg 165 -selfg 9 -cursorfg 3 &
        setenv CONSOLE true
        xwsh -title console -icontitle console -geometry 80x40+0-2 -fn "*-lucidatypewriter-bold-*-*-*-*-8-100-100-*" \
            -fg 54 -bg 0 -selbg 165 -selfg 9 -cursorfg 3 &
    endif

    # set some user preferences using the XSET(1) utility
    xset fp+ /usr/lib/fmfonts -art 40 -ari 3 &

    # make a granite-textured root-window background
    #/usr/bin/X11/xsetroot -bitmap /usr/include/X11/bitmaps/granite -fg \#043 -bg black

    # the magic last client. when this client exits, the session is terminated
    /usr/bin/X11/reaper




The following framed examples show parts of the (standard SGI) .Xdefaults file. Click here for explanation while your look through the source codes.



    !  Define some customizations for xwsh

    xwsh*background:               #00466a
    xwsh*foreground:               grey80
    xwsh*cursorTextColor:          white
    xwsh*cursorPageColor:          red
    xwsh*barPointerShape:          spider

    XWsh*clientDecoration:         +minimize +maximize +menu +border
    XWsh*autoFork:                 on
    XWsh*selectionTextColor:       white
    XWsh*selectionPageColor:       163
    XWsh*geometry:                 80x24
    XWsh*barWidth:                 10
    XWsh*font:                     -*-lucidatypewriter-medium-r-normal-*-14-140-*
    XWsh*OverFirst:                true
                          :
                          :





Also the ".Xdefaults" file is used to set Window Manager resources:



    !              4Dwm settings

    !  These resources apply to icon management
    4Dwm*iconPlacement:                 top left
    4DWm*iconDecoration:                image
    4Dwm*iconImageMaximum:              64x77
    4Dwm*icon*fontList:                 -*-courier-bold-r-normal-*-12-*
    4Dwm*iconPlacementMargin:           0

    4Dwm*useIconBox:                    False
    4Dwm*iconbox*clientDecoration:      none

    4DWm*clientAutoPlace:               false

    !  define the icon tiling area with the following 4 boundary edges:
    4DWm*SG_iconPlacementLeftMargin:    90
    4DWm*SG_iconPlacementRightMargin:   280
    4DWm*SG_iconPlacementBottomMargin:  678
    4DWm*SG_iconPlacementTopMargin:     768

    !  Set the foreground color (which is the text) for the
    !  client window  title bar that currently has the input focus.
    4Dwm*activeForeground:              gold

    !   Set the background color (the title bar itself which is
    !   "behind the text") for the client window title bar that
    !   currently has the input focus.
    4Dwm*activeBackground:              deepskyblue4
                               :
                               :





The followings show ".Xdefaults" use for setting the look of various programs (clients). More information is given here.



    !   The following resources define what the 4Dwm frames will
    !   look like for specific clients.
    !   The values explicitly listed specify various elements of
    !   the window manager frame.
    !   Specifying a "+" means "add this element", while no other frame elements are drawn;
    !                "-" means "subract this element" but otherwise leave other elements untouched;
    !             "none" means paint no window manager frame at all.
    4Dwm*xterm*clientDecoration:   +resize +minimize
    4Dwm*xeyes*clientDecoration:   +title
    4Dwm*xbiff*clientDecoration:   +border
    4Dwm*xclock*clientDecoration:  none
    4Dwm*Xman*clientDecoration:    -menu -maximize

    ! make all apps not explicitly defined above have the
    ! following client decoration resources turned on.
    *clientDecoration:             +resizeh +border +minimize +maximize +menu

    ! paint ipaste images without any border (use Meta or rightShift-RightControl
    ! -RIGHTMOUSE to get 4Dwm menu).
    *ipaste*clientDecoration:      none
    *xarchie*clientDecoration:     none
    *xfig*clientDecoration:        none
    *xfig.geometry:                1024x768+0+0
    *xmailtool*clientDecoration:   none
    *xmailtool.geometry:           666x764-0+0
    irit*Trans*BackGround:         NavyBlue
    irit*Trans*Geometry:           =150x500+500+0
    irit*Trans*CursorColor:        Green
    irit*View*BackGround:          NavyBlue
    irit*View*BorderColor:         Red
    irit*View*BorderWidth:         3
    irit*View*Geometry:            =500x500+0+0
    irit*View*CursorColor:         Red

    !  These define key, button and window menu specifications for 4Dwm.
    !  The values given to these resources must be defined in $HOME/.4Dwmrc
    4Dwm*keyBindings:              myKeyBindings
    4Dwm*buttonBindings:           myButtonBindings
    4Dwm*windowMenu:               4DwmWindowMenu





As mentioned in the discussion of the ".xsession" file, it is usual to separate the ".Xdefaults" resource specifications into a number of different files representing display sizes. The typical resources which change are geometry placement, and font sizes but need not be limited to those.

The frame below indicates the format of the key, button and menu binding file for the 4Dwm Window Manager on SGs. It is typical of the Motif Window Manager. This is the main way of tailoring your window environment - keys may be changed, keys may be programmed to do various things in conjunction with mouse button events. These Motif events "f.xxxx" are used to propagate real events to the user and his/her environment. A similar mechanism is used in other Window Managers - see the equivalent file for the X11R5 distribution in a later frame.

The frame after the definitions shows the various menus that are used by later key and button definitions. For example, the "rootMenu" is shown when the right mouse button is clicked in the root window. (This is not hardwired in - I could have chosen the left mouse button or the middle mouse button when the Meta or Alt key is pressed - it is completely user definable ( remember though that there are certain historical conventions). )

As mentioned previously, this file contains a definition for the window menu specified in the ".Xdefaults" file:

4Dwm*windowMenu:            4DwmWindowMenu





    ############################################################
    #
    #  NAME
    #       $HOME/.4Dwmrc - sample file for customizing menus,
    #       key and button bindings for 4Dwm(1X).
    #
    #  DESCRIPTION
    #
    #    The .4Dwmrc file can be used to customize:
    #      1) What happens when specific KEY and MOUSE BUTTONS
    #         are pressed when the pointer is over any part of the 
    #         screen (e.g. the root window, a window's frame, an icon, etc.).
    #      2) What items appear in the WINDOW MENU.
    #      3) What  items  appear in the ROOT MENU--the pop-up
    #         menu that appears when you press a mouse button over
    #         any part of the root window.
    #
    #  REFERENCES
    #
    #      1)  4Dwm(1X)
    #      2)  mwm(1X)
    #      3)  "OSF/Motif Programmer's Guide" (especially Part II,
    #          Motif Window Manager, Chapter 5, Managing Menus,
    #          Mouse Buttons, and Keyboard Bindings)
    #      4)  O'Reilly, Vol. 3, Part 4, Appendix C, the OSF/Motif
    #          Window Manager pp. 610-629, 3rd Edition, May 1990
    #
    ################################################################

    ################################################################
    #
    #                          Menu Pane Description
    #
    #     The following 5 menu definitions (starting 70 lines below)
    #     demonstrates various customizations one can specify for their own
    #     menu set.
    #
    #     The syntax for this type of structure is as follows:
    #
    #     menu menu_name
    #     {
    #         label [mnemonic] [accelerator]  function
    #                .
    #                .
    #         label [mnemonic] [accelerator]  function
    #     }
    #
    #     The entries above are defined as:
    #
    #     label         this string appears as a selectable menu item.
    #                   If the string "no-label" is specifed here, 4Dwm
    #                   will place a "separator" (horizontal bar) in the
    #                   menu to separate other labels.
    #
    #     mnemonic      a character which, if pressed while the menu is
    #                   active, will select the associated menu item.
    #
    #     accelerator   a key sequence which activates a window manager function
    #
    #     function      an action which the window manager can perform. The
    #                   following functions are used in this file:
    #
    #      f.exec       causes the command following it to be executed
    #                   (using the value of the MWMSHELL environment
    #                   variable if it is set, otherwise the value of the
    #                   SHELL environment variable if it is set, otherwise
    #                   /bin/sh).
    #
    #      f.kill       ends execution of a client.
    #
    #      f.lower      pushes a client window to the bottom of the window stack.
    #
    #      f.maximize   causes a client window to be displayed with its 
    #                   maximum size (in most cases this means make the window
    #                   fill the screen).
    #
    #      f.menu       associates a pull-right or roll-over menu with a menu
    #                   pane entry, or a menu with a button or key binding.
    #                   The menu_name function argument identifies the menu to be used.
    #
    #      f.minimize   causes a client window to be iconified or stowed.
    #
    #      f.move       causes a client window to be interactively moved.
    #
    #      f.normalize  causes a client window to be displayed with its normal
    #                   (de-iconified or de-maximized) size.
    #
    #      f.post_wmenu  posts the window menu. If a key is used to post the
    #                    window menu and a window menu button is present,
    #                    the  window menu is automatically placed with its
    #                    top-left corner at the bottom-left corner of the
    #                    window menu button for the client window. If no window
    #                    menu button is present, the window menu is placed
    #                    at the top-left corner of the client window.
    #
    #      f.quit_apps  ends execution of the current application.
    #
    #      f.quit_mwm   ends execution of the 4Dwm window manager (but NOT the X window system).
    #
    #      f.raise      pops a client window to the top of the window stack.
    #
    #      f.restart    causes 4Dwm to be restarted (effectively sending terminate
    #                   and re-execute commands sequences to the X server).
    #
    #      f.refresh    causes all windows to be redrawn.
    #
    #      f.resize     causes a client window to be interactively resized.
    #
    #      f.separator  causes a menu separator to be drawn in the menu at 
    #                   the specified location (the label is ignored).
    #
    #      f.title      inserts a title in the menu at the specified location.
    #
    ##############################################################








    ##############################################################
    #
    #
    #   The following are the menu definitions used for 4Dwm.
    #   These will supersede the definitions in /usr/lib/X11/system.mwmrc.
    #   Menus that are defined in this file are not used by the
    #   window manager until they are explicitly specified as
    #   a target of an "f.exec" call. This may be done in a
    #   another menu definition, or a key or button binding definition.
    #   For example, the "rootMenu" definition below is referenced in
    #   our button binding definition farther below.
    #   In this way, any menu can be associated with any given context.
    #
    menu "rootMenu"
    {
        "root menu"           f.title
        "logout"              f.exec "/usr/bin/X11/endsession"
         no-label             f.separator
        "CNNews"              f.exec "xwsh -name CNNews -geometry 80x40+152+102 -e /usr/local/bin/nn"
        "backgrounds"         f.menu backs
         no-label             f.separator
        "refresh"             f.refresh
        "restart"             f.restart
         no-label             f.separator
        "kill 4Dwm"           f.quit_mwm
    }

    menu backs
    {
        "Window Roots"        f.title   
        "Default Root"        f.exec "xsetroot -solid sgilightblue"
        "lightblue Root"      f.exec "xsetroot -solid sgibackgroundblue"
        "Cross-weave Root"    f.exec "xsetroot -def"
        "Escher-Knot Root"    f.exec "xsetroot -bitmap /usr/include/X11/bitmaps/escherknot -fg SGITeal -bg sgilightgray"
        "Wingdogs Root"       f.exec "xsetroot -bitmap /usr/include/X11/bitmaps/wingdogs -fg SGITeal -bg sgilightgray"
        "Mensetmanuw Root"    f.exec "xsetroot -bitmap /usr/include/X11/bitmaps/mensetmanus -fg SGITeal -bg sgilightgray"
        "Tina Turner Root"    f.exec "xsetroot -bitmap /usr/include/X11/bitmaps/woman -fg SGITeal -bg sgilightgray"
    }

    menu "clients"
    {
        "Console"             f.exec "xwsh -title console -icontitle console -geometry 80x40+0-2 -fn
        "snapshot"            f.exec "snapshot -b"
        "showmap"             f.exec "showmap"
        "makemap"             f.exec "makemap"
        "cedit"               f.exec "cedit"
        "snoop"               f.exec "/usr/demos/bin/snoop"
        "calendar"            f.exec "/usr/sbin/ical &"
        "camera alignment grid (grid)"   f.exec "/usr/sbin/grid"
        "color bars (colorbars)"         f.exec "/usr/sbin/colorbars"
        "gamma calibration field (gamcal)"   f.exec "/usr/sbin/gamcal"
         no-label             f.separator
        "xwsh"                f.exec "/usr/sbin/xwsh &"
        "xterm"               f.exec "xterm -n `hostname` &"
         no-label             f.separator
        "xmag"                f.exec "xmag &"
        "xclock"              f.exec "xclock -analog -bg black -fg red -hd red -hl red&"
        "xcalc"               f.exec "xcalc &"
        "xedit"               f.exec "xedit &"
        "xload"               f.exec "xload -bg black -fg red &"
        "xshowcmap"           f.exec "xshowcmap &"
         no-label             f.separator
        "display info (xdpyinfo)"       f.exec "xwsh -geometry 80x24+110+427 -name 'X Query: Display Info' -hold -e /usr/bin/X11/xdpyinfo"
        "window info (xwininfo)"        f.exec "xwsh -geometry 80x24+110+427 -name 'X Query: Window Info' -hold -e info" /usr/bin/X11/xwininfo" 
        "properties (xprop)"            f.exec "xwsh -geometry 80x24+110+427 -name 'X Query: Properties' -hold -e /usr/bin/X11/xprop"
        "font names (xfontsel)"         f.exec "/usr/bin/X11/xfontsel"
    }

    menu "hosts"
    {
        "xwsh:  "    f.exec "xwsh -name welcome -max 111x49 -geometry 80x40 -fn
    }

    ###########################################################
    #
    #   Default Window Menu Description which has been explicitly
    #   overriden/redefined here to include different text
    #   for the menu items. This is then specified as the value
    #   for the 4Dwm*windowMenu resource in the ~4Dgifts/.Xdefaults file.
    #
    menu 4DwmWindowMenu
    {
        "pop"            f.raise
        "push"           f.lower
        "move"           f.move
        "resize"         f.resize
        "stow"           f.minimize
        "open"           f.normalize
        no-label         f.separator
        "close"          f.kill
        "quit"           f.quit_app
    }




The following frame shows the button bindings of the SG 4Dwmrc file. The first entry -

     <Btn1Click>        frame           f.raise

indicates that when a Btn1Click is detected and the cursor is over the frame of a window then the f.raise event will be invoked.


     Shift Ctrl<Btn1Down>    window      f.raise_resize

indicates that when the Shift and Control keys are pressed and Button number 1 is down and the cursor is inside a window then the f.raise_resize event is invoked. And so on.

As mentioned previously, this file contains a definition for the button bindings specified in the ".Xdefaults" file:

     4Dwm*buttonBindings:                myButtonBindings





    ################################################################
    #
    #                       Button Binding Description
    #
    #     The syntax for this type of structure is as follows:
    #
    #     buttons bindings_set_name
    #     {
    #         button     context     function
    #                :
    #         button     context     function
    #     }
    #
    #     The syntax for the context specification is
    #
    #     context = object[|context]
    #     object  = root | icon | window | title | frame | border | app
    #
    #     The context specification indicates where the mouse
    #     cursor must be for the button binding to be effective.
    #     For example, a context of `window' indicates that the
    #     pointer must be over a client window or window manager
    #     frame for the button binding to be effective. The
    #     `frame' context is for the window manager frame around a
    #     client window (including the border and titlebar), the
    #     `border' context is for the border part of the window
    #     manager frame (not including the titlebar), the `title'
    #     context is for the title area of the window manager
    #     frame, and the `app' context is for the application
    #     window (not including the window manager frame).
    #
    #     If a function is specified in a type of resource  where
    #     it is not supported or is invoked in a context that
    #     does not apply, the function is treated as f.nop (no
    #     operation is performed).
    #
    ##############################################################

    ##############################################################
    #
    #     The following button bindings override the 4DwmButtonBindings
    #     located  in  the  /usr/lib/X11/system.4Dwmrc file.
    #     myButtonBindings is defined to be the current resource
    #     for button bindings in the $HOME/.Xdefaults file of the
    #     ~4Dgifts directory.
    #
    buttons myButtonBindings
    {
             <Btn1Click>    frame           f.raise
             <Btn1Click>    icon            f.normalize
          Ctrl<Btn1Down>    frame|icon      f.lower
         Shift<Btn1Down>    frame|icon      f.raise

    Shift Ctrl<Btn1Down>    window          f.raise_resize

              <Btn2Down>    frame|icon      f.move
          Ctrl<Btn2Down>    frame|icon      f.lower
         Shift<Btn2Down>    frame|icon      f.raise
    Shift Ctrl<Btn2Down>    window          f.raise_move

              <Btn3Down>    frame|icon      f.post_wmenu
          Ctrl<Btn3Down>    frame|icon      f.post_wmenu
         Shift<Btn3Down>    frame|icon      f.post_wmenu
          Meta<Btn3Down>    window|icon     f.post_wmenu
    Shift Ctrl<Btn3Down>    window          f.post_wmenu

              <Btn1Down>    root            f.menu clients
              <Btn2Down>    root            f.menu hosts
              <Btn3Down>    root            f.menu rootMenu

    #  Exercise extensive care when binding things to the meta key.
    #  This can be costly to emacs and other applications see below.
          Meta<Btn1Down>    frame           f.raise_lower
          Meta<Btn2Down>    frame           f.move

    # Here is how to make an emacs user grumpy.
    #     Meta<Btn1Down>    window          f.raise_lower
    #     Meta<Btn2Down>    window          f.move
          Meta<Btn1Down>    window          f.minimize

    }





And the key bindings. The Meta key is normally the one marked Alt on the keyboard. As mentioned previously, this file contains a definition for the key bindings specified in the ".Xdefaults" file:

4Dwm*keyBindings:           myKeyBindings




    ##############################################################
    #
    #                         Key Binding Description
    #
    #    The  following key bindings override the 4DwmKeyBindings
    #    located in the /usr/lib/X11/system.4Dwmrc file.
    #    myKeyBindings is defined to be the current resource for
    #    key bindings in the $HOME/.Xdefaults file of the ~4Dgifts
    #    directory.
    #
    #    The key binding syntax is:
    #
    #    keys bindings_set_name
    #    {
    #       key        context     function
    #              :
    #       key        context     function
    #    }
    #
    keys myKeyBindings
    {
        Meta<Key>w       root           f.refresh
        Meta<Key>w       icon|window    f.refresh_win
        Meta<Key>r       window         f.resize
        Meta<Key>m       window         f.move
        Meta<Key>a       window         f.raise_lower
        Meta<Key>i       root           f.minimize_all
        Meta<Key>i       window         f.minimize
        Meta<Key>o       root           f.normalize_all
        Meta<Key>b       window         f.maximize
        Meta<Key>k       window         f.kill

        # the following key definitions are ripped whole-hog out
        # of /usr/lib/X11/system.4Dwmrc to maintain this functionality

        # Same as the standard OSF Key Bindings
            Shift<Key>Escape       window|icon         f.post_wmenu
            Meta<Key>space         window|icon         f.post_wmenu
            Meta<Key>Tab           root|icon|window    f.next_key
            Meta Shift<Key>Tab     root|icon|window    f.prev_key
            Meta<Key>Escape        root|icon|window    f.next_key
            Meta Shift<Key>Escape  root|icon|window    f.prev_key
            Meta Shift Ctrl<Key>exclam  root|icon|window  f.set_behavior
            Meta<Key>F6            window              f.next_key transient
            Meta Shift<Key>F6 window                   f.prev_key transient
            <Key>F4           icon          f.post_wmenu
    #        <Key>Right       window         f.maximize
    #        <Key>Left        window         f.normalize
    #        <Key>Up          window         f.raise
    #        <Key>Down        window         f.lower

        # SGI added key bindings
            Shift<Key>Escape       root      f.menu 4DwmRootMenu
            Meta<Key>space         root      f.menu 4DwmRootMenu
    }




A similar file exists for twm - the X11R5 distributed Window Manager - ".twmrc". The following frames show some of the control structure for the file. Firstly the overall control:



    ## TWM control file
    #   Version:    2.52
    #   Date:       30/6/92

    AutoRelativeResize        # Don't require resize to cross border to start
    BorderWidth  2            # Width of top level windows created by TWM
    ClientBorderWidth         # Use the application border width on frame
    ConstrainedMoveTime 0     # turn off horizontal/vertical only moving
    #DecorateTransients       # Put titlebars on transients
    DontMoveOff               # Prevent windows leaving our screen
    DontSqueezeTitle
    NoCaseSensitive           # Turn off case-sensitivity in icon sorting
    NoGrabServer              # Don't grab server during menus, etc.
    NoRaiseOnMove             # Allow moving under other windows
    NoRaiseOnResize           # Allow resizing under other windows
    NoSaveUnders              # Faster to just repaint than save
    NoTitleFocus              # Avoid keystrokes in wrong window due to lag
    RestartPreviousState      # Re-iconify iconified things on startup
    UsePPosition "on"         # Program-specified size hints accepted

    Zoom 128

    IconFont "lucidasanstypewriter-18"
    IconManagerFont "lucidasanstypewriter-18"
    MenuFont "lucidasanstypewriter-14"
    ResizeFont "lucidasanstypewriter-18"
    TitleFont "lucidasanstypewriter-16"




Then application specific control of events:



    NoTitle
    {
        "xclock"
        "xbiff"
        "Xman"
    }

    WindowRing
    {
        "XTerm"
        "Xarchie"
        "ups"
    }

    AutoRaise
    {
        "XTerm"
        "Xarchie"
        "ups"
        "xv"
    }

    Cursors
    {
        Button "top_left_arrow"
        Destroy "pirate"
        Icon "top_left_arrow"
        IconMgr "top_left_arrow"
        Frame "top_left_arrow"
        Menu "top_left_arrow"
        Move "top_left_arrow"
        Resize "top_left_arrow"
        Select "crosshair"
        Title "top_left_arrow"
        Wait "watch"
    }

    Monochrome
    {
        BorderColor "white"
        DefaultBackground "black"
        DefaultForeground "white"
        MenuTitleBackground "black"
        MenuTitleForeground "white"
        MenuBackground "black"
        MenuForeground "white"
        MenuShadowColor "white"
        IconBackground "black"
        IconForeground "white"
        IconBorderColor "white"
        IconManagerBackground "black"
        IconManagerForeground "white"
        IconManagerHighlight "white"
    }

    Color
    {
        BorderColor "slategrey"
        DefaultBackground "maroon"
        DefaultForeground "gray85"
        TitleBackground "maroon"
        TitleForeground "gray85"
        MenuBackground "maroon"
        MenuForeground "gray85"
        MenuTitleBackground "gray70"
        MenuTitleForeground "maroon"
        IconBackground "maroon"
        IconForeground "gray85"
        IconBorderColor "gray85"
        IconManagerBackground "maroon"
        IconManagerForeground "gray85"
    }

    #IconManagerGeometry   "236x1-0+0"
    IconRegion             "240x240-0+0" NORTH WEST 80 80
    IconRegion             "120x160-0+240" NORTH EAST 80 80
    UnknownIcon            "xlogo32"

    Icons

                                                                     {
        "XTerm"          "terminal"
    }





Now key and button binding with associated functions which can be invoked. (For example

      Button1 = m : window|icon : f.function "move-or-lower"
means when button 1 is clicked and the Meta key is also pressed in a window or an icon then invoke function "move-or-lower" defined previously).




    #
    # Define some useful functions for motion-based actions.
    #
    DefaultFunction f.nop

    MoveDelta 3

    Function "move-or-lower"       { f.move f.deltastop f.lower }
    Function "move-or-raise"       { f.move f.deltastop f.raise }
    Function "move-or-iconify"     { f.move f.deltastop f.iconify }

    #
    # Set some useful bindings. Sort of uwm-ish, sort of simple-button-ish
    #
    Button1 = : root : f.menu "hosts"
    Button2 = : root : f.menu "apps"
    Button3 = : root : f.menu "defops"

    Button1 = m : window|icon : f.function "move-or-lower"
    Button2 = m : window|icon : f.iconify
    Button3 = m : window|icon : f.function "move-or-raise"

    Button1 = : title : f.function "move-or-raise"
    Button2 = : title : f.raiselower
    Button3 = : title : f.menu "windowmenu"

    Button1 = : icon : f.function "move-or-iconify"
    Button2 = : icon : f.iconify
    Button3 = : icon : f.menu "iconmenu"

    Button1 = : iconmgr : f.iconify

    # SUN4 "Stop" key
    "L1" = : icon | iconmgr | window : f.destroy
    "L1" = s : icon | window : f.delete
    "L1" = c : all : f.restart
    "L1" = m : all : f.quit

    "Help" = : all : f.identifY





And lastly the menus that can be invoked.



    menu "iconmenu"
    {
        "Icon"           f.title
        "Open"           f.iconify
        "Raise/Lower"    f.raiselower
        "Refresh"        f.winrefresh
        "Quit"           f.delete
        "Kill program!"  f.destroy
    }

    menu "sunhosts"
    {
        "SUN's"          f.title
        "abel"           f.exec "xterm -title abel -e rlogin abel &"
        "cain"           f.exec "xterm -title cain -e rlogin cain &"
        ""               f.nop
                   :
        "tutte"          f.exec "xterm -title tutte -e rlogin tutte &"
    }

    menu "indigohosts"
    {
        "Indigo's"       f.title
        "lillee"         f.exec "xterm -title lillee -e rlogin lillee &"
        "marsh"          f.exec "xterm -title marsh -e rlogin marsh &"
    }
                :

    menu "hosts"
    {
        "Hosts"          f.title
        "SUN's"          f.menu "sunhosts"
        "Indigo's"       f.menu "indigohosts"
        "SG's"           f.menu "sgihosts"
        "DECstation's"   f.menu "dechosts"
    }

    menu "windowmenu"
    {
        "Window"         f.title
        "Iconify"        f.iconify
        "Raise/Lower"    f.raiselower
        "Refresh"        f.winrefresh
        "Resize"         f.resize
        "Quit"           f.delete
        "Kill Window!"   f.destroy
    }

    menu "Applications"
    {
        "Applications"   f.title
        "Calculator"     f.exec "xcalc &"
        "Calendar"       f.exec "xcalendar &"
        "Font list"      f.exec "xfontsel &"
        "Image viewer"   f.exec "xv &"
        "Mail reader"    f.exec "xmail &"
        "Manual pages"   f.exec "xman &"
    }

    menu "winops"
    {
        "Windows"        f.title
        "Iconify"        f.iconify
        "Move"           f.move
        "Resize"         f.resize
        "Raise"          f.raise
        "Lower"          f.lower
        "Kill"           f.destroy
        "Delete"         f.delete
    }

    menu "iconmgr"
    {
        "Icon Manager"   f.title
        "Show"           f.showiconmgr
        "Hide"           f.hideiconmgr

    }

    menu "defops"
    {
        "Twm"            f.title
        "Windows"        f.menu "winops"
        "Icon Manager"   f.menu "iconmgr"
        ""               f.nop
        "Focus"          f.focus
        "Unfocus"        f.unfocus
        ""               f.nop
        "Refresh"        f.refresh
        ""               f.nop
        "Version"        f.version
        "Restart"        f.restart
        "Exit"           f.quit
    }