Tiny Core Linux

Tiny Core Extensions => TCE Q&A Forum => Topic started by: whoisterence on January 28, 2011, 10:58:43 PM

Title: Setting Environment Variable with Extension Script
Post by: whoisterence on January 28, 2011, 10:58:43 PM
Trying to set some environment variable in extension script.

For example, created extension scim.tcz with the script in usr/local/tce.installed/scim (file permission: -rwxr-xr-x 1 root root)
...
export XMODIFIERS=@im=SCIM
export GTK_IM_MODULE=scim
export QT_IM_MODULE=scim
...

but the variables are not set, because when I echo $XMODIFIERS after loading tcz, it's empty.  How to do this?
Title: Re: Setting Environment Variable with Extension Script
Post by: gerald_clark on January 29, 2011, 12:31:37 AM
You can't.
You will have to modify a profile or rc file.
Title: Re: Setting Environment Variable with Extension Script
Post by: Arslan S. on January 29, 2011, 02:50:10 AM
isn't /etc/profile.d used for this purpose ?

just put a file say scim.sh under /etc/profile.d

in this case scim.sh would be:
Code: [Select]
export XMODIFIERS=@im=SCIM
export GTK_IM_MODULE=scim
export QT_IM_MODULE=scim

a relogin or reboot is needed for changes to take effect
Title: Re: Setting Environment Variable with Extension Script
Post by: Rich on January 29, 2011, 05:11:52 AM
Hi whoisterence
Try this:

             source scim

That should do what you are looking for.
Title: Re: Setting Environment Variable with Extension Script
Post by: maro on January 29, 2011, 10:27:04 PM
... or reboot is needed for changes to take effect

AFAIK the re-login should be enough (but a re-boot being the more "drastic" measure would work as well).

The critical thing from my POV would be that the file in '/etc/profile.d' has a *.sh name, and is available early enough for the inital login. The latter point should be feasible either by inclusion to the backup, or via an OnBoot extension.
Title: Re: Setting Environment Variable with Extension Script
Post by: whoisterence on February 01, 2011, 12:26:54 PM
Rich, 'source scim' would work at prompt, but scim.sh is suppose to run at extension mount which doesn't source the extension script.

The purpose of scim is to try to export the variables system-wide.

/etc/profile.d  sounds like the extension must be loaded at boot.
Title: Re: Setting Environment Variable with Extension Script
Post by: curaga on February 01, 2011, 02:06:07 PM
Quote
/etc/profile.d  sounds like the extension must be loaded at boot.

Yes. There is no way to inject variables to a running session.