Running C program from icon - [SOLVED]

Running C program from icon - [SOLVED]

Postby gaumaugher on Fri Oct 12, 2012 12:52 pm

I have a c program that runs well from xterminal. I enter ./prog1 and it does what I expect, displaying what I want to see in the window. Now I want to run this program from a desktop icon but I cannot find a way to do it, again within a terminal window. I am sure this is a simple task but I can find nothing on the web that helps guide me to the solution. I would like to click on an icon and have a terminal window open and my program run. My program required input to terminate. Any assistance is appreciated.
Last edited by gaumaugher on Wed Oct 17, 2012 6:14 am, edited 2 times in total.
gaumaugher
Level 1
Level 1
 
Posts: 6
Joined: Fri Oct 12, 2012 12:29 pm

Linux Mint is funded by ads and donations.
 

Re: Running C program from icon

Postby remoulder on Fri Oct 12, 2012 2:34 pm

What version of mint, what desktop?
[Edit] your original post and add [SOLVED] once your question is resolved.

“The people are my God” stressing the factor determining man’s destiny lies within man not in anything outside man, and thereby defining man as the dominator and remoulder of the world.
User avatar
remoulder
Level 17
Level 17
 
Posts: 7667
Joined: Fri May 09, 2008 1:14 pm

Re: Running C program from icon

Postby gaumaugher on Fri Oct 12, 2012 3:19 pm

Version 13 with default desktop.
gaumaugher
Level 1
Level 1
 
Posts: 6
Joined: Fri Oct 12, 2012 12:29 pm

Re: Running C program from icon

Postby remoulder on Fri Oct 12, 2012 4:13 pm

There is no 'default' desktop. Please supply output of
Code: Select all
inxi -Sx
[Edit] your original post and add [SOLVED] once your question is resolved.

“The people are my God” stressing the factor determining man’s destiny lies within man not in anything outside man, and thereby defining man as the dominator and remoulder of the world.
User avatar
remoulder
Level 17
Level 17
 
Posts: 7667
Joined: Fri May 09, 2008 1:14 pm

Re: Running C program from icon

Postby gaumaugher on Sat Oct 13, 2012 2:24 am

$ inxi -Sx
System: Host: EPRI-GW Kernel: 3.2.0-23-generic i686 (32 bit, gcc: 4.6.3) Desktop: Gnome Distro: Linux Mint 13 Maya

I assumed it was Gnome but someone else loaded the OS on this computer.
gaumaugher
Level 1
Level 1
 
Posts: 6
Joined: Fri Oct 12, 2012 12:29 pm

Re: Running C program from icon

Postby remoulder on Sat Oct 13, 2012 7:02 am

Ok will assume it's cinnamon, so to answer your question, right mouse the menu and choose Edit menu. In the menu editor, select the category on the left you want the item to be in then click the New Item button. fill in the details for your application ensuring you tick the Run in terminal box. Save exit the editor and test it works. Once you're happy, right mouse the item in the menu and select Add to desktop.
[Edit] your original post and add [SOLVED] once your question is resolved.

“The people are my God” stressing the factor determining man’s destiny lies within man not in anything outside man, and thereby defining man as the dominator and remoulder of the world.
User avatar
remoulder
Level 17
Level 17
 
Posts: 7667
Joined: Fri May 09, 2008 1:14 pm

Re: Running C program from icon

Postby gaumaugher on Sun Oct 14, 2012 9:23 pm

You are good! That worked perfectly but I ran into one roadblock I cannot get around. I can click on the icon and it runs perfectly but I cannot add it to the startup group. I can go to menu->preferences->startup and add a program but the edit box does not have the type selector required to specify it to run in a terminal. I couldn't find a way of copying an icon into this group or dragging it in. Is there a back door to adding a program to the startup group from another group?
gaumaugher
Level 1
Level 1
 
Posts: 6
Joined: Fri Oct 12, 2012 12:29 pm

Re: Running C program from icon

Postby remoulder on Mon Oct 15, 2012 5:48 am

gaumaugher wrote:Is there a back door to adding a program to the startup group

Now that you have the desktop icon, the easiest way is to open the file manager at your home, turn on hidden files in the view menu or using Ctrl+H, then copy the .desktop file for your app from your Desktop folder to ~/.config/autostart where ~/ means your home and . indicates a hidden folder. It should then appear in Startup Apps but 'may' not run properly due to various quirks. If that is the case there are other options.
[Edit] your original post and add [SOLVED] once your question is resolved.

“The people are my God” stressing the factor determining man’s destiny lies within man not in anything outside man, and thereby defining man as the dominator and remoulder of the world.
User avatar
remoulder
Level 17
Level 17
 
Posts: 7667
Joined: Fri May 09, 2008 1:14 pm

Re: Running C program from icon

Postby gaumaugher on Mon Oct 15, 2012 8:29 am

That did get it into the startup group and it shows up when I open preferences->startup but unfortunately it doesn't run. I thought maybe it was attempting to run and then exiting before the system was completely ready so I added a 30 second sleep to the start of the program. No such luck.

I can create a terminal session in a script with:
/usr/bin/gnome-terminal
I put the script in the the startup group and it starts fine. Is there a way to feed in my startup command into the terminl from the script?
gaumaugher
Level 1
Level 1
 
Posts: 6
Joined: Fri Oct 12, 2012 12:29 pm

Re: Running C program from icon

Postby remoulder on Mon Oct 15, 2012 9:44 am

If you have created a script, just add your app to that. Alternatively you could just use the sh ... command (possibly with a -i param) in the startup launcher command to start your app, man sh
[Edit] your original post and add [SOLVED] once your question is resolved.

“The people are my God” stressing the factor determining man’s destiny lies within man not in anything outside man, and thereby defining man as the dominator and remoulder of the world.
User avatar
remoulder
Level 17
Level 17
 
Posts: 7667
Joined: Fri May 09, 2008 1:14 pm

Re: Running C program from icon - [SOLVED]

Postby gaumaugher on Wed Oct 17, 2012 6:33 am

All of the higher level solutions I tried did not work but by adding a desktop entry file to ~/.config/autostart worked beautifully. The format was:
[Desktop Entry]
Type=Application
Exec=gnome-terminal -x /home/user1/projects/prog1
Hidden=false
X-GNOME-Autostart-enabled=true
Name[en_US]=prog1.desktop
Name=prog1
Comment[en_US]=My C test program
Comment=

With this, if you can create a program launcher that works from the desktop, it appears to work from the autostart. Thanks for all the help!
gaumaugher
Level 1
Level 1
 
Posts: 6
Joined: Fri Oct 12, 2012 12:29 pm

Linux Mint is funded by ads and donations.
 

Return to MATE

Who is online

Users browsing this forum: No registered users and 2 guests

cron