I have a desktop entry pointing to IntelliJ IDEA
IDE. I wanted to add . ~/.bashrc
at the beginning of the idea.sh
script that is being executed by Desktop Entry. The point of that is that IDEA wasn't picking up my modified SSH_AUTH_SOCK
env variable, that was defined there. So I added a very simple . ~/.bashrc
at the beginning of idea.sh
, to discover that the sourced code is not being run. Now some details.
In ~/.bashrc
I have this:
# Set GPG TTY
export GPG_TTY=$(tty)
unset SSH_AGENT_PID
if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
fi
# Refresh gpg-agent tty in case user switches into an X session
gpg-connect-agent updatestartuptty /bye >/dev/null
I wanted this to run at the beginning of idea.sh
, but . ~/.bashrc
doesn't work, HOWEVER if I put this exact code directly in the idea.sh
, in the same place, it will work just fine.
Sourcing also works if I run idea.sh
directly in my terminal. It doesn't work only if I run it by using Desktop Entry. The desktop entry in question is /home/luken/.local/share/applications/jetbrains-idea.desktop
:
[Desktop Entry]
Version=1.0
Type=Application
Name=IntelliJ IDEA Ultimate Edition
Icon=/home/luken/Programy/idea-IU-182.4505.22/bin/idea.svg
Exec="/home/luken/Programy/idea-IU-182.4505.22/bin/idea.sh" %f
Comment=Capable and Ergonomic IDE for JVM
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-idea
So to sum this up:
Running idea.sh
in terminal:
#!/bin/sh
#
# ---------------------------------------------------------------------
# IntelliJ IDEA startup script.
# ---------------------------------------------------------------------
#
. ~/.bashrc
echo "${SSH_AUTH_SOCK}" > ~/auth.txt
# ...
Content of auth.txt
: /run/user/1000/gnupg/S.gpg-agent.ssh
CORRECT.
Running idea.sh
by using Desktop Entry shortcut:
#!/bin/sh
#
# ---------------------------------------------------------------------
# IntelliJ IDEA startup script.
# ---------------------------------------------------------------------
#
. ~/.bashrc
echo "${SSH_AUTH_SOCK}" > ~/auth.txt
# ...
Content of auth.txt
: /run/user/1000/keyring/ssh
INCORRECT.
#!/bin/sh
#
# ---------------------------------------------------------------------
# IntelliJ IDEA startup script.
# ---------------------------------------------------------------------
#
# Set GPG TTY
export GPG_TTY=$(tty)
unset SSH_AGENT_PID
if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
fi
# Refresh gpg-agent tty in case user switches into an X session
gpg-connect-agent updatestartuptty /bye >/dev/null
echo "${SSH_AUTH_SOCK}" > ~/auth.txt
# ...
Content of auth.txt
: /run/user/1000/gnupg/S.gpg-agent.ssh
CORRECT.
Anyone have any idea what is going on here or how to debug this?
VAR="variable" executable
.source
is part of this script.