• Aucun résultat trouvé

Working with resources

Dans le document XII Guide (Page 115-120)

A resource is a characteristic, such as a color, font, or window size, that affects the behavior or appearance of a client application. All client applications have certain predefined resource values. You can customize the behavior of client applications by assigning new values to these resources. Understanding the concepts of resource management greatly increases your ability to customize your configuration according to your needs.

• Note: For a complete list of the resources that can be set for a client application, see the client application's manual page in Xll Command Reference for A/UX.

Chapter 5 Customizing Xll 5-27

030-1732-A

XII obtains resource values from the following sources:

• global resources stored in the server

• application-specific resources stored in the /usr/lib/X11/app-defaults directory

• user-specific resources stored in a file whose name is set in the XENVIRONMENT variable

• temporary resources specified at the command line with the -x rm flag option

Global resources

Global resources are stored directly on the server where they are available to all client applications that communicate with the server.

The X protocol provides a mechanism that allows you to use the xrdb client application to load a global resource file into the server's resource database. When a client application needs the value of a resource, it searches this database for the needed resource. If the needed values are found in the resource database, these values override any predefined resource values.

• Note: In older versions of X Window System, global resources were stored in a file named. Xdefaul ts. For compatibility, if you do not use xrdb to load global resources in the server, client applications will look in your home directory for

. Xdefaul ts. Using the. Xdefaul ts file is similar to using the resource database, but it is less flexible because client applications running on remote hosts may not have access to a local. Xdefaul ts file. When you use xrdb, resource values are available to client applications running on both local and remote computers.

Application-specific resources

Application-specific resources set defaults for client applications running on a particular host computer. Each client application may have a resource file in the / u s r /1 ib / X 11/ a pp-defaul t s directory. When a client application needs the value of a resource, it searches this directory for a file with its name. For example, the pathname of an application-specific resource file for xterm is /usr / lib/X11 / app-defaul ts /XTerm.

5-28 XU User's Guide for A/UX

030-1732-A

If the client application finds an application-specific resource file, it searches this file for the needed resource. If the needed values are found, these values override any predefined resource values and values specified in the resource database.

• Note: Because application-specific resource files reside in the / us r /1 ib directory, they affect all users of the host computer.

User-specific resources

User-specific resources are similar to application-specific resources, but they allow users to set defaults that won't affect other users. You can specify resource values for a client application in a file and then set the XENVIRONMENT variable to point to that file. When a client

application needs the value of a resource, it searches the specified file for the needed resource. If the needed values are found, these values override any predefined resource values and values specified in the resource database and /usr / lib/X11 / app-defaul ts

directory.

Temporary resources

Temporary resources affect a single invocation of a client application. You use the

-xrrn command-line flag option to specify temporary resources. Resources specified at the command line override any previously set resource values.

Setting resources

Resource specifications follow this syntax:

clientApplication* resource: value

where value can be a string value (such as foreground: red), a numeric value

(borderwidth: 1), or a Boolean value (scrollBar: on).

Chapter 5 Customizing XII 5-29

030-1732-A

The following examples specify resource values for the xterrn client application:

xterm*foreground: red xterm*borderwidth: 1 xterrn*scrollBar: on

• Note: For details about the syntax of resource specifications, see x(1X) in Xll Command Reference for )jUX.

Client applications determine resource values in the following order, with later values overriding earlier values:

• global resources

• application-specific resources

• user-specific resources

• temporary resources To set global resources

1. Create a rue with an Alux text editor and specify the desired resources.

2. Give the HIe a name that identiftes it as an X resource fue.

For example, you can use. Xres as the filename.

3. Use the xrdb client application to load the resource fue into the server.

For example, use this command:

xrdb -load .Xres

Assume the following is part of a global resource file:

XTerrn*scrollBar: on

Unless overriding values have been set, whenever xterm opens on this server, it will display a scroll bar.

For more information about xrdb, see xrdb(1X) in Xll Command Reference for AlUX.

5-30 X11 User's Guide for A/UX

To set application-specific resources

1. Create a ftle with an A/UX text editor and specify the desired resources for a client application.

2. Give the ftle the same name as the client application and store it in the

/usr / lib/Xll / app-de£aul ts directory.

For example, this is part of an application-specific resource file for xclock:

xclock*digital:on

Unless overriding values have been set, whenever a user opens the xclock client application on this host computer, the clock displays the time in digital format.

To set user-specific resources

1. Create a ftle with an A!UX text editor and specify the desired resources.

2. Give the ftle a name that identifies it as an X environment fue.

For example, you can use. Xenv as the filename.

3. Depending on which shell you use, do the following:

o If you use the C shell, add the XENVIRONMENT variable to your. cshrc file to point to the pathname of your environment file.

For example, add this line to your. cshrc file:

setenv XENVIRONMENT $HOME/.Xenv

o If you use the Bourne shell or Korn shell, add these lines to your . pro f i 1 e file:

XENVIRONMENT=$HOME/.Xenv export XENVIRONMENT

Values in the environment file override any previously set values.

To set temporary resources

You can use the -xrm flag option when you open a client application at the command line to temporarily override default resources. For example, this command opens xclock with a blue foreground and a yellow background:

xclock -xrm "Foreground: blue" -xrm "Background: yellow" &

Chapter 5 Customizing Xll 5-31

030-1732-A

6 Important When you create or modify resource files, make sure you follow the format and syntax specified on the client application's manual page in Xli Command Reference for AlUX. L.

Dans le document XII Guide (Page 115-120)