Re: Re: Modifying the environment

Jim Knoble <[email protected]>
Newsgroups gmane.compw.window-managers.windowmaker.user
Message-ID <[email protected]>
Circa 2005-06-16 dixit Ted Stern:

: On 16 Jun 2005 at 11:01 UTC-0700, Martin Gagnon wrote:
: > Similar idea, I just think about something, but I never try it. It
: > should work.
: >
: > In your .xinitrc or whatever you use, call a script that look like that:
: >
: > ---->
: > #!/bin/sh
: >
: > while [[ 0 == 0 ]]; do
: >     ~/.environment.sh
: >     wmaker
: > done
: > <----
: 
: The '[[ 0 == 0 ]]' syntax is overkill, and is not Bourne-shell
: compatible.  It happens to work because your /bin/sh is really running
: bash/ksh/zsh or something with Korn shell extensions.

Not only that, but the script above has two problems:  (1) the
environment is not actually set due to a typographical error (line 4
should begin with ". "); and (2) with the error in [1] corrected, there
is a hidden side effect: environment variables that have been set once
in ~/.environment.sh, but then removed or commented out, will not be
removed from the environment.  The only way around this is to use 'unset
VARIABLENAME' in ~/.environment.sh, or to change the script:

    #!/bin/sh
    while :; do
        ( . ~/.environment.sh
          exec wmaker
        )
    done

This runs Window Maker in a subshell, so the environment is destroyed
once Window Maker exits.  The 'exec' keyword keeps the subshell from
hanging around and using up a process slot for no reason.

It's also not possible to cleanly exit this infinite loop; that's why
something like switchwm is a better choice.

Good luck.

-- 
jim knoble  |  [email protected]  |  http://www.pobox.com/~jmknoble/
(GnuPG fingerprint: 809F:09B9:9686:D035:4AB0::9455:124B:0A62:DD6A:76D6)
 .....................................................................
 :"The methods now being used to merchandise the political candidate :
 : as though he were a deodorant positively guarantee the electorate :
 : against ever hearing the truth about anything."   --Aldous Huxley :
 :...................................................................:
_______________________________________________
INFO: https://windowmaker.org/lists/listinfo/wm-user
ARCHIVE: https://windowmaker.org/lists/archive/wm-user/
FAQ: http://windowmaker.org/faq.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.