0

The following command from terminal works perfectly:

sh /home/flux/Downloads/TeamSpeak3-Client-linux_amd64/ts3client_runscript.sh

How would I go about adding this as a shortcut, so I can open teamspeak from my Unity Launcher panel on the left without using the terminal?

Jacob Vlijm
  • 83,767
  • 1
    @muru definitely a look-alike, only nothing about bash or shell there... – Jacob Vlijm Sep 24 '14 at 07:56
  • @JacobVlijm then we'd have to have question for every interpreter out there: the shells, the pythons, the perls, the phps, the bfs, the gnuplots, .... – muru Sep 24 '14 at 08:01
  • @muru I partially agree, but believe mainly the last section (bash -c) is somewhat outside the scope of the other question. – Jacob Vlijm Sep 24 '14 at 08:10
  • @JacobVlijm I disagree. The scope of the other question is simple creating launchers. It does not say for what. bash -c is no different than firefox -new-window. – muru Sep 24 '14 at 08:13
  • 1
    @muru strictly yes, but running bash commands from the launcher is a subsection of the subject that could use some attention on its own; it is a bit more than – Jacob Vlijm Sep 24 '14 at 08:21
  • @JacobVlijm I'd prefer not, in this case. I feel strongly that your answer belongs there and not here. However, that's a flag I will raise if this gets closed. – muru Sep 24 '14 at 08:22
  • 1
    My apologies for the duplicate question. I did attempt to find a similar thread. Though the suggestion from your link regarding "Alacarte" was perfect - this tool helped me create the shortcut a lot easier than the manual method. Thanks! – PiedPiper Sep 25 '14 at 09:48

1 Answers1

2

In its most basic form:

create a .desktop file (paste the text below in an empty file):

[Desktop Entry]
Name=Start Teamspeak
Exec=/bin/bash /home/flux/Downloads/TeamSpeak3-Client-linux_amd64/ts3client_runscript.sh
Icon=/path/to/your/icon
Type=Application

save the file as team.desktop in ~/.local/share/applications and drag it from there on to the launcher.

Explanation

Running scripts from a .desktop file

If you run a script in the Exec= line from a launcher like this, it works like in the terminal:

  • If the script is not executable:

    language /path/to/script.language_extension
    
  • If the script is executable, just:

    /path/to/script.sh
    

    If the script is executable, the language extension is not strictly needed. However, if you use it on the file, also use it in the command.

Running more complicated shell commands from a .desktop file

Exec=/bin/bash -c "your_complicated_command_here"
(command inside quotes)
Jacob Vlijm
  • 83,767
  • Is need to use sh here Exec=sh /home/flux/Downloads/TeamSpeak3-Client-linux_amd64/ts3client_runscript.sh. sh after Exec=sh<--this – αғsнιη Sep 24 '14 at 07:19
  • @KasiyA I am afraid I don't understand what you mean? – Jacob Vlijm Sep 24 '14 at 07:19
  • 1
    @KasiyA yes, if the script is not executable the sh is needed, otherwise it won't hurt. – Jacob Vlijm Sep 24 '14 at 07:22
  • thank you I didn't know that. We can execute script by itself with adding chmod +x scriptName.sh and remove the sh behind Exec= – αғsнιη Sep 24 '14 at 07:24
  • IMHO Never use sh as the interpreter on scripts unless the script is known to be sh-compatible. Prefer bash, if the user mentions bash. – muru Sep 24 '14 at 07:51