WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Setting Environment Variable with Extension Script  (Read 3240 times)

Offline whoisterence

  • Newbie
  • *
  • Posts: 27
Setting Environment Variable with Extension Script
« 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?

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: Setting Environment Variable with Extension Script
« Reply #1 on: January 29, 2011, 12:31:37 AM »
You can't.
You will have to modify a profile or rc file.

Offline Arslan S.

  • Hero Member
  • *****
  • Posts: 825
Re: Setting Environment Variable with Extension Script
« Reply #2 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
« Last Edit: January 29, 2011, 09:10:49 AM by Arslan S. »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11581
Re: Setting Environment Variable with Extension Script
« Reply #3 on: January 29, 2011, 05:11:52 AM »
Hi whoisterence
Try this:

             source scim

That should do what you are looking for.

Offline maro

  • Hero Member
  • *****
  • Posts: 1228
Re: Setting Environment Variable with Extension Script
« Reply #4 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.

Offline whoisterence

  • Newbie
  • *
  • Posts: 27
Re: Setting Environment Variable with Extension Script
« Reply #5 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.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11043
Re: Setting Environment Variable with Extension Script
« Reply #6 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.
The only barriers that can stop you are the ones you create yourself.