2

A bit of background

I'm a developer and I install most of my tools in my home folder. So my shell's rc file is full of JAVA_HOME, GROOVY_HOME, MAVEN_HOME, ... variables. To expose all these environment variables to my GUI applications (think my IDE) I used to write a shell script by first defining those variables again and then running the application; and finally adding a launcher in my application menu to run that script.

One day I realized that I could just run my application via my shell. As all the variables defined in the shell's rc files were going to be set in the application environment. So the entry in my application menu became something like /usr/bin/my-shell ~/my-ide/bin/start.sh

Now the question

Can I instruct my DM to always use my shell to run all my applications?

Side notes

I use ZSH and Gnome, but a more generic solution would be appreciated.

I've already set my default shell to ZSH, but Gnome doesn't seem to considered that a good enough reason to use that shell for everything.

1

Some suggestions:

  1. Keep the variables in a file that does nothing but set variables, so you can easily source it with . my-dev-vars.sh.

  2. Source that file once in your login shell, (.profile, .bash_profile, see Wikipedia for a good list of config files for login shells). That ensures that you get the rights variables when you login remotely.

  3. Also source the file in your ~/.xinitrc or ~/.xsession (some distros have other variants, see X11 docs); that ensures that your desktop X11 session have the vars, too.

Goal should be to define them once, source them once for any process group. Then they really are "environment" variables, and work as designed.

This also has the advantage over your current solution that it isn't spawning extra shells needlessly.

0

Yes,

Modify the xdg-open command or exo-open on xfce4 (which is a binary program)

That's how the DE opens a file or program.

But you should modify /etc/{zshrc,profile} like stuff if you want these settings global.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.