I see. I had assumed there was a simple way to tell. I'm coming from the Windows platform where a console application has one bit set in the program's header by the linker (or not set if it's a GUI app.) Maybe I'll just leave this one as a terminal app, at least for now. I just think it sucks that if you double-click on it, nothing happens.
On Sep 22, 12:17 am, Joe Wollard <[email protected]> wrote: > Ah, I see what you're asking now. Sorry about that. The only thing > that comes to mind is an examination of the process lineage. This is > shooting from the hip, but perhaps if the program is launched from the > terminal, its immediate parent would be bash or sh or similar. I'm not > sure what the parent process would be in gnome though. Maybe gnome- > session? > > Like I said, I'm shooting from the hip on this one. There's bound to > be a more elegant way of doing what you need. You might look at some > of the system-config-* scripts from the fedora project. I believe they > kind of do what you need. They are written in python, but they might > be a good starting point if nothing else. > > --- > Joe Wollard > > On Sep 22, 2009, at 1:01 AM, Dos-Man 64 <[email protected]> wrote: > > > > > > > Is it that complicated just for the application to tell if the user > > executed it from a terminal session? I can easily write wrap 2 > > versions of the app (C++) in the same executable, the problem is I > > can't tell which version to "run" if I can't tell if the program was > > invoked from a shell session. > > > On Sep 21, 11:53 pm, Joe Wollard <[email protected]> wrote: > >> You need to research the MVC (model, view, controller) pattern. Using > >> that programing pattern is going to help you write code that can use > >> the exact same bacground logic yet still use the native display > >> language. e.g. Qt for KDE, gtk for Gnome, or good ol text for the > >> terminal. > > >> It's tough to wrap your head around it at first, but once you've got > >> it you won't want to program any other way. > > >> Happy coding! > > >> --- > >> Joe Wollard > > >> On Sep 22, 2009, at 12:05 AM, Dos-Man 64 <[email protected]> wrote: > > >>> I'm just finishing up my first utility that shows the amount of > >>> memory > >>> and the amount of free memory. It's a terminal app. I'm > >>> wondering if > >>> it can also be a GUI app or is it common to create 2 different > >>> versions? From a programming perspective, I'm not sure how to tell > >>> if the application is executing in a shell session or not... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Linux Users Group. To post a message, send email to [email protected] To unsubscribe, send email to [email protected] For more options, visit our group at http://groups.google.com/group/linuxusersgroup -~----------~----~----~----~------~----~------~--~---
