1

I want an icon, which I can double click to execute a terminal command. So far I've created an executable script:

#!/bin/bash

gnome-terminal -e cd ~/gPodder/Downloads/M4As\ To\ Be\ Converted/ && for f in *.m4a; do avconv -i "$f" "${f/%m4a/wav}"; done && for i in *.wav; do opusenc --bitrate 26 --downmix-mono "$i" "${i/%wav/opus}"; done && find . -type f -iname \*.wav -delete

Since I've just thrown things together kind of arbitrarily I'm not surprised it doesn't work, so what do I have to change in order for it to open a new terminal window executing the specified sequence of commands?

The actual command (starting from cd to -delete) actually works when manually entered in a terminal window.

Jacob Vlijm
  • 85,475

3 Answers3

3

Use a .desktop file to call the script, put this in a text file and save it with the extension .desktop

[Desktop Entry]
Name=My script
Comment=Runs my script
Exec=
Icon=
Terminal=false
Type=Application

On the exec line you can put the path of your script, same for an icon.

You then make this file executable with chmod +X or by right click and go to permissions.

You can add this to the launcher or any location you like and click it to run the script.

Mark Kirby
  • 18,949
  • 19
  • 79
  • 116
1
  1. Create a launcher that will execute your command on your desktop
  2. move launcher to /usr/share/applications
  3. set read and execute permissions on launcher file so that every user can access and execute it.

Detailed answer: https://askubuntu.com/a/68023/332981

gogeccc
  • 343
  • 2
  • 12
0

It's much easier if you create a separate script, let's say ~/bin/foobar, starting with the proper "shebang" line (e.g. #!/bin/bash), give it executable permissions, and then ask gnome-terminal to run this script, i.e. gnome-terminal -e foobar.

If you really need to inline the complex command line, start with this proof of concept:

gnome-terminal -e 'bash -c "cd somewhere; ls; sleep 10"'

and if you can confirm that it works then replace the innermost command line with whatever you'd prefer there, replacing " by \" everywhere.

egmont
  • 8,990
  • 1
  • 34
  • 47