.desktop file with .bashrc environment
I am using IntelliJ IDEA, and it uses some of the environment variables defined in the .bashrc script.
If I run its shell script from the terminal everything works fine but if I create a .desktop file to run it from the launcher then it is loaded without the .bashrc environment.
I also tried using the "Run with terminal" option and it doesn't help. Is there a way to do those things?
The content of the desktop file:
[Desktop Entry]
Version=1.0
Type=Application
Name=IntelliJ IDEA
Icon=/home/gmarom/bin/idea-IU-135.1230/bin/idea.png
Exec="/home/gmarom/bin/idea-IU-135.1230/bin/idea.sh" %f
Comment=Develop with pleasure!
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-idea
Moving the environment variables to .profile
didn't work for me. Instead, I removed the code that @oliman suggests from my .bashrc
and then I changed the my IntelliJ IDEA's launcher from this:
"/opt/idea-IU-163.12024.16/bin/idea.sh" %f
to this:
bash -c "source ~/.bashrc && /opt/idea-IU-163.12024.16/bin/idea.sh %f"
When running from a launcher, the idea.sh script is started using a non-iteractive shell. In your .bashrc
make sure the environment variables are exported before
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
Or alternatively place the environment variable exports in ~/.bash_profile