Ubuntu build application shortcut for terminal application
I wanted to run llama.cpp from applications menu. I wanted to:
- Open new terminal window
- Change directory to llama.cpp folder
- Run llamaswap with certain parameters
Following the working how to do it:
Here’s the key change in the Exec
line:
-
Exec=gnome-terminal --working-directory=/home -- bash -c "ls -lrt; exec bash"
-
gnome-terminal --working-directory=/home
: This part remains the same, launching the terminal and setting the working directory to/home
. -
--
: This separates thegnome-terminal
options from the command thatgnome-terminal
itself should execute. -
bash -c "..."
: This tells the terminal to execute a string as a bash command. -
"ls -lrt; exec bash"
: This is the command string passed tobash -c
.-
ls -lrt
: This is the command you want to run (list files in long format, reverse time order). -
;
: This is a command separator, meaningexec bash
will run afterls -lrt
completes. -
exec bash
: This is crucial! Afterls -lrt
finishes,exec bash
replaces the current shell process with a new interactive bash shell. Withoutexec bash
, the terminal window would close immediately afterls -lrt
finishes, as there would be no more commands for the initialbash -c
process to execute.
-
-
[Desktop Entry]
Name=Llama Swap
Comment=Launch Llama Swap in terminal
Exec=gnome-terminal --working-directory=/home/tipu/Applications/llamacpp/ -- bash -c "./llama-swap --config config.yaml --listen :8888 --watch-config; exec bash"
Icon=utilities-terminal
Terminal=false
Type=Application
Categories=Development;