TL;DR
[Desktop Entry]
Version=1.0
Name=Hello
Exec=sh -c 'echo hello; $SHELL'
Icon=utilities-terminal
Terminal=true
Type=Application
As stated in desktop entry specification, Terminal=true
tells the launcher to launch your script in a terminal window. The chosen Terminal Emulator depends on your default applications settings and Desktop Environment. In GNOME, it is gnome-terminal, in KDE, it is Konsole. (Without DE, in plain WM there is a bug in xdg-open, and Terminal=true
just ignored, see issue)
You need this line to run your script and launch a shell after it.
Exec=sh -c 'echo hello; $SHELL'
sh -c 'COMMAND'
run the "sh" binary found in $PATH which
executes COMMAND (on many systems, sh
is the symbolic link to
bash
, but for portability "sh" is prefered)
echo hello; $SHELL
does two things. First, it runs echo hello
and then, after the execution of this command, launches $SHELL.
If you will not add some command that waits for you to exit, a terminal emulator will just run your program and exit.
P.S. If you just want not to close your terminal, you can do
Exec=sh -c 'echo hello; read'
Or
Exec=sh -c 'echo hello; sleep 5'
(read will wait for you to press Enter, sleep will just wait 5 seconds)
P.P.S $SHELL
probably will be the same as last section in /etc/passwd
in line with your user.
$ man login
The value for $HOME, $USER, $SHELL, $PATH, $LOGNAME, and $MAIL are set
ac‐
cording to the appropriate fields in the password entry.