Running C program from icon - [SOLVED]

Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
gaumaugher

Running C program from icon - [SOLVED]

Post by gaumaugher »

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 LockBot on Wed Dec 28, 2022 7:16 am, edited 3 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
remoulder
Level 17
Level 17
Posts: 7621
Joined: Fri May 09, 2008 1:14 pm

Re: Running C program from icon

Post by remoulder »

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.
gaumaugher

Re: Running C program from icon

Post by gaumaugher »

Version 13 with default desktop.
remoulder
Level 17
Level 17
Posts: 7621
Joined: Fri May 09, 2008 1:14 pm

Re: Running C program from icon

Post by remoulder »

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.
gaumaugher

Re: Running C program from icon

Post by gaumaugher »

$ 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.
remoulder
Level 17
Level 17
Posts: 7621
Joined: Fri May 09, 2008 1:14 pm

Re: Running C program from icon

Post by remoulder »

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.
gaumaugher

Re: Running C program from icon

Post by gaumaugher »

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?
remoulder
Level 17
Level 17
Posts: 7621
Joined: Fri May 09, 2008 1:14 pm

Re: Running C program from icon

Post by remoulder »

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.
gaumaugher

Re: Running C program from icon

Post by gaumaugher »

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?
remoulder
Level 17
Level 17
Posts: 7621
Joined: Fri May 09, 2008 1:14 pm

Re: Running C program from icon

Post by remoulder »

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.
gaumaugher

Re: Running C program from icon - [SOLVED]

Post by gaumaugher »

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!
Locked

Return to “MATE”