TOC PREV NEXT INDEX

Put your logo here!


6 PECS (Pluggable Environment Contribution System)

6.1 A CRASH-COURSE IN BOURNE SHELL

What follows is a little cookbook of common things you may wish to put in your ~/.pecs/*.env files:

To set a variable do this:

VARIABLE1=value

VARIABLE2="value with spaces"

export VARIABLE1 VARIABLE2

(Notice there are no spaces around the '='; bourne shell is sensitive

about this.)

To safely test if a variable is set do this:

if [ "X$VARIABLE" != X ]; then

code to do if VARIABLE is set

else

code to do if VARIABLE is not set

fi

To set an alias, put something like this in your

~/.pecs/misc-all.ali file:

alias ALIASNAME="alias value"

(e.g: alias ls="/bin/ls -a")

A switch statement looks like this:

case "$VARIABLE" in

value1) do this

and then this

and this is last ;;

value2) do this

and something else ;;

*) this is the default action ;;

esac

If you want to do a tcsh rehash, you should do:

hash -r

6.2 USER ENVIRONMENT SETTINGS

PECS supports personal settings for the following types of settings:

- environment variables

- X resources

- GUI root window menu items

- shell aliases

All personal settings belong in files in the ~/.pecs directory, which should exist and contain (comments-only) example files. The big problem with putting a setting in one of these files, is knowing which file to put it in! This section explains the steps to determine where to put a setting:

1. Decide the 'type' of the setting

Four 'types' of personal settings are supported by PECS:

a. environment variables (type=env)
b. X resources (type=xrdb)
c. GUI root menu items (type=wmrc)
d. shell aliases (type=ali)

If the setting you wish to make is one of the above types, then you should note down what 'type' it is.

If the setting you want to make is not one of these then it is a setting outside the scope of PECS and you should make the setting in another way.

This may mean that you put the setting in a file where the program will look (e.g. putting settings for FTP in ~/.netrc) or it may mean that you put the setting in a file in which the program will check due to locally modified behaviour (e.g. personal emacs settings go ~/.emacs.local).

Consult your application or system adminstrators if you are unsure how to do this.

2. Decide the 'application-scope' of the setting

Settings either:

a. relate to a PECS-aware application (application-scope=apps)
(e.g. VLTROOT, INTROOT, GNU_ROOT, NOCCS, PRINTER, RTAP_EXISTS)
b. don't relate to a PECS-aware application (application-scope=misc)
(e.g. DFLOW_ROOT because it relates to older versions of VLTSW only, NNTPSERVER, LESS, MAIL, PATH=$HOME/bin:$PATH).

3. Decide the 'host-scope' of the setting

Settings either:

a. are applicable only on certain hosts (host-scope=<name-of-host>)
b. are applicable on all hosts (host-scope=all)

4) Put the setting in the right file

Now that you've worked out the three attributes 'type', 'application-scope' and 'host-scope', it's easy; the setting belongs in the file:

~/.pecs/<application-scope>-<host-scope>.<type>

e.g., to change your prompt set 'PS1' in ~/.pecs/apps-all.env, and

to change your VLTROOT set VLTROOT in the same file.

5) Activating the setting

To activate the change in setting first run:

make_xdefaults

and then log out and back in.

Let's look at a couple of examples; consider each of the following

settings, look at the values it has for each attribute, and see the

name of the file it goes in.

Example #1: Changing VLTROOT

Suppose you're working on a machine where VLTROOT is set to /vlt/MAR2001/CCS, and you need to point it at FEB2000 instead just for a quick test. Well,

it's an environment variable (type=env)

it relates to VLTSW, which is a PECS-aware application (application-scope=apps)

you only need it for a quick test on host 'te13' (host-scope=te13)

So, having worked that out, the setting belongs in the file:

~/.pecs/apps-te13.env

So, in the file you just put:

VLTROOT=/vlt/FEB2000/CCS

Note that environment variables supported by a PECS-aware application are automatically made available to sub-processes ('exported') so you do not need to export it yourself (though it does no harm to do so).

Example #2: the 'which' alias

Yes, the 'which' command under Bourne-like shells does not work quite the same as it did under Tcsh. Under Bash, the nearest equivalent to 'which' is 'type' or 'type -all'. So to make 'which' an alias for 'type -all':

it's a shell alias (type=ali)

it's not related to a PECS-aware application, it's just personal setting (application-scope=misc)

you want it everywhere (host-scope=all)

So, having worked that out, the setting belongs in the file:

~/.pecs/misc-all.ali

So, in the file you just put:

alias which='type -all'

Aliases are read per-shell-process, so it is not necessary to log out; your next new xterm will see the alias.

Note that Bash aliases have an '=' between the alias and its value, unlike Tcsh.

Example #3: you want to add 'top' and 'xv' to your 'User Menu'

PECS provides a GUI root window sub-menu entitled 'User Menu'. Suppose you want to create the menu to contain the command

'top'

it's a GUI root window menu item (type=wmrc)

it's not related to a PECS-aware application (the user menu never is) (application-scope=misc)

you want to see this menu everywhere (host-scope=all)

So, having worked that out, the setting belongs in the file:

~/.pecs/misc-all.wmrc

So, in the file you put:

Menu user_menu

{

"My Menu" f.title

"Top" f.exec "xterm -T top -n top -e top"

"Xv" f.exec "xv"

}

Note that 'top' isn't on all systems, so simply calling 'top' is a bit naive.

To activate the settings select 'Restart' from the GUI root window menu.

Example #4: you don't like the Xclock updating every second

PECS allows you to specify new values for X resources, but it also allows you to 'unset' existing ones (this is not a standard behaviour of X).

You will probably find your Xclocks showing a second hand, because of the X resource:

XClock*update: 1

To cancel this setting, just provide a blank value for it. So,

it's an X resource (type=xrdb)

it's related to a PECS-aware application (yes, this resource is defined by VLTSW)

(application-scope=apps)

you want to see this menu everywhere (host-scope=all)

So, having worked that out, the setting belongs in the file:

~/.pecs/apps-all.xrdb

So, in the file you put:

XClock*update:

To activate the change you need to log out and log in again.

Example #5: you don't like to use

"export VARIABLE=VALUE"

and you want to keep using

"setenv VARIABLE VALUE"

Very bad idea, but if you are so obstinate, you should write a function, because aliases which require embedded parameters must be written as functions, but should still be put in the ".ali" file. Here's an example:

export_function()

{

export $1=$2

}

alias setenv=export_function

Enjoy!

____oOo____



Quadralay Corporation
http://www.webworks.com
Voice: (512) 719-3399
Fax: (512) 719-3606
sales@webworks.com
TOC PREV NEXT INDEX