Find the answer to your Linux question:
Results 1 to 3 of 3
I've tried about a dozen different methods, from creating a scripting file which does nothing than export MYVAR=whatever, to trying to create a menu option in openbox with <command>export MYVAR=whatever</command>, ...
  1. #1
    Just Joined!
    Join Date
    Sep 2008
    Location
    Southwest Kansas
    Posts
    57

    Exporting environ variable from within a wm?

    I've tried about a dozen different methods, from creating a scripting file which does nothing than export MYVAR=whatever, to trying to create a menu option in openbox with <command>export MYVAR=whatever</command>, and many other trials, too. Even exporting through a terminal doesn't do it either.

    Granted, I'm certain this is just not possible, so the only other option that seems to be doable...

    What I'm trying to do, be able to switch wm's from the menu in Openbox, and the keyboard in dwm...

    In my .xinitrc file I have a while loop setup to continuously run while the environment variable MYWM != "".

    This is what I thought about, all-be-it a little messy, which is why I haven't tried it yet...

    In a directory I would create a file which has nothing more than the wm's I want to run.

    wm.conf file.
    Code:
    /directory/dwm/dwm
    openbox-session
    Therefore, I could create a script file that would grep the wm.conf file and write it to another file, to which then would be exported from within the .xinitrc file itself...Or, I am certain there is some program, I think awk could do this, where I could create a script file that all the wm would be commented out, and therefore, the script within .xinitrc could eliminate the comment character to which then the wm script file would run. Then immediately afterwards it would have to be recommented to insure that X would shut down.

    Anyway, any thoughts or other ideas?

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    There is no easy way to do this. Placing a loop in your .xinitrc file is a REALLY bad idea, IMO. Your best option is the following (in pseudo-code - procedural operations to use) - this assumes that your users are running bash and not csh or other shells:

    1. In your menu/script to set the variable, write the value to a file accessible to the /etc/bashrc script - for the purposes of this example, use the name '.myxvars'.
    2. Modify /etc/bashrc to look for ~/.myxvars and if found to source it as in
    Code:
    if [ -f ~/.myxvars ]; then
        . ~/.myxvars
    fi
    This will then work for all users if a shell is used to spawn an X windows client. However, if they are spawned directly then ~/.bashrc might not be executed and consequently neither will /etc/bashrc. Try it and see if this works.

    Note that xinitrc is only used to start a user's X session. I don't think that modifying .xinitrc will do what you think, which is why I said before not to do what you were proposing.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Sep 2008
    Location
    Southwest Kansas
    Posts
    57
    I have tried a few other things which no matter what I tried the env variable MYWM never changed.

    Anyway, I already have my .profile setup so I can just type in the wm I wish to use, such as startdwm which would create a env variable MYWM=/dir/dwm then in my .xinitrc file I have it edited with "exec $MYWM". It works.

    Well, none the less, for the time being it seems to be impossible to switch wm's without exiting X...Eh, just a minor nuisance...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...