Run a Script Shell with double click on Ubuntu

1

I have a program in Shell, it does the installation and configuration of some programs in Ubuntu, I wanted to know how to compile it or make it run when the user double-clicks it, yesterday I had found a C program that does this, but I lost the code and could not find it anymore.

    
asked by anonymous 21.08.2015 / 00:34

3 answers

2

Well an easy way I found as I said, was to create a C program that runs the script and open the terminal.

Code in C: (main.c)

#include<stdio.h>
#include<stdlib.h>

main(void)
{
    system("gnome-terminal --command '/opt/shell.sh'");
}

And then compile with:

gcc -o executal main.c

Then put it on the desktop and the shell.sh in / opt

    
22.08.2015 / 22:01
6

In Ubuntu 15.04:

Open Nautilus and click the Edit menu in Preferences. In the window that opens, click on the Behavior tab and check one of the options indicated by the arrows.

Inaddition,yourfileneedstobeexecutepermission.Thesamecanbegrantedviathecommandline:

chmod+xarquivoShell.sh

orviaNautilus.Forthiscase,rightclickonthedesiredfileandselectProperties.

    
22.08.2015 / 11:52
3

You can do this by creating a file with a .desktop extension. You must give Run permission by clicking Properties and selecting the appropriate check box. (see picture of answer above). Note that in the Icon option you can specify a valid image file (do your tests), in my example, a folder icon will appear. Must be encoded as UTF-8.

I discovered this on my own, but found some related articles desktop-file and How to create launcher shortcuts on the desktop .

Script:

#!/usr/bin/env xdg-open
[Desktop Entry]
Name=teste
Comment=Programinha para teste
TryExec=/home/helcio/Programas/exemplo
Exec=/home/helcio/Programas/exemplo
Icon=folder
Terminal=true
Type=Application
    
07.03.2016 / 02:49