How can I make a launcher open a terminal and run another command?

0
3
Asked By MellowCactus47 On

I'm using Linux Mint with XFCE and want one-click launchers for things like starting games and running maintenance tasks. I already use a .desktop file, but Steam and an update command that should launch my own shell script do nothing when clicked. I've tried launching xterm and other terminal emulators without success. What's the correct way to configure the launcher so it opens the default terminal and executes the command or script?

3 Answers

Answered By CopperLynx6 On

Steam probably shouldn't be started through a terminal at all. Use its full executable path in `Exec`, for example `Exec=/usr/bin/steam` and `Terminal=false`. For update tasks that need administrator privileges, let `sudo` or a graphical privilege tool prompt for the password rather than putting a password in the script or weakening the sudo configuration.

Answered By VelvetComet8 On

For a .desktop launcher, use the `Terminal=true` key instead of hard-coding `xterm`. XFCE should then use the system's configured terminal emulator. A basic launcher could look like this:

`[Desktop Entry]`
`Type=Application`
`Name=System Update`
`Exec=/home/yourname/bin/update-system.sh`
`Terminal=true`
`Path=/home/yourname/bin`

Make sure the script has a valid shebang, such as `#!/bin/bash`, and is executable with `chmod +x /home/yourname/bin/update-system.sh`. Using an absolute path is important because desktop launchers may not have the same PATH or working directory as your interactive shell.

Answered By QuietMaple22 On

If the script finishes immediately, the terminal may open and close so quickly that it looks like nothing happened. Add something like `read -rp "Press Enter to close..."` at the end while testing. Also try running the exact command directly in a terminal first; that will reveal missing permissions, commands, or environment variables.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.