Skip to main content

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 the gnome-terminal options from the command that gnome-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 to bash -c.

      • ls -lrt: This is the command you want to run (list files in long format, reverse time order).

      • ;: This is a command separator, meaning exec bash will run after ls -lrt completes.

      • exec bash: This is crucial! After ls -lrt finishes, exec bash replaces the current shell process with a new interactive bash shell. Without exec bash, the terminal window would close immediately after ls -lrt finishes, as there would be no more commands for the initial bash -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;