Re: [SOLVED]Re: how to know if I'm using xterm or gnome-terminal?

2010-02-25 Thread A. Racca
On Thu, 2010-02-25 at 11:44 -0500, Jake Peavy wrote: 
 On Wed, Feb 24, 2010 at 2:56 PM, Germán A. Racca
 german.ra...@gmail.com wrote:
 On Tue, 2010-02-23 at 15:41 -0500, Nalin Dahyabhai wrote:
  On Tue, Feb 23, 2010 at 04:52:32PM -0300, Germán A. Racca
 wrote:
   Hi all:
  
   How to know if I'm using an xterm or a gnome-terminal from
 command line?
  
   The output of echo $TERM is xterm from both of them.
  
   How to know?
 
  James Wilkinson already outlined why most environment
 variables probably
  shouldn't be trusted, so I'll suggest checking the output of
xprop -id $WINDOWID WM_CLASS
 
  HTH,
 
  Nalin
 
 
 Thanks to all that answered my question with a lot of useful
 suggestions.
 
 Finally, I decided to use Nalin's suggestion and implement the
 following
 command to know if I'm using an xterm or a gnome-terminal:
 
 xprop -id $WINDOWID WM_CLASS | awk '{print $3}' | sed 's///g'
 | sed
 's/,//g'
 
 which returns either xterm or gnome-terminal. 
 
 
 
 for me xprop -id $WINDOWID WM_CLASS returns WM_CLASS: not found.
 
 This is on F11, Gnome terminal 2.26.1.
 
 ?

In my case it is Fedora 12 and gnome-terminal 2.28.2
Germán.

-- 
Germán A. Racca
National Institute for Space Research (INPE)
São José dos Campos - SP - Brasil
http://sites.google.com/site/gracca
http://gracca.wordpress.com

-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines


[SOLVED]Re: how to know if I'm using xterm or gnome-terminal?

2010-02-24 Thread A. Racca
On Tue, 2010-02-23 at 15:41 -0500, Nalin Dahyabhai wrote: 
 On Tue, Feb 23, 2010 at 04:52:32PM -0300, Germán A. Racca wrote:
  Hi all:
  
  How to know if I'm using an xterm or a gnome-terminal from command line?
  
  The output of echo $TERM is xterm from both of them.
  
  How to know?
 
 James Wilkinson already outlined why most environment variables probably
 shouldn't be trusted, so I'll suggest checking the output of
   xprop -id $WINDOWID WM_CLASS
 
 HTH,
 
 Nalin

Thanks to all that answered my question with a lot of useful
suggestions.

Finally, I decided to use Nalin's suggestion and implement the following
command to know if I'm using an xterm or a gnome-terminal:

xprop -id $WINDOWID WM_CLASS | awk '{print $3}' | sed 's///g' | sed
's/,//g'

which returns either xterm or gnome-terminal.

Cheers,
Germán.
-- 
Germán A. Racca
National Institute for Space Research (INPE)
São José dos Campos - SP - Brasil
http://sites.google.com/site/gracca
http://gracca.wordpress.com

-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines


Re: how to know if I'm using xterm or gnome-terminal?

2010-02-23 Thread James Wilkinson
Germán A. Racca wrote:
 How to know if I'm using an xterm or a gnome-terminal from command line?
 
 The output of echo $TERM is xterm from both of them.
 
 How to know?

Well, it looks as though gnome-terminal sets $COLORTERM, whereas xterm
doesn’t. But xterm doesn’t unset it, either, so if you get a user
starting up a gnome-terminal, thinking “Yuck!”¹ and using that
gnome-terminal solely to run xterm, then the xterm will inherit the
$COLORTERM setting.

Xterm has its own $XTERM_ variables, so you could test for those. But
gnome-terminal doesn’t unset those, either, so you could get a user
starting up am xterm, thinking “Yuck!”¹ and using that xterm solely to
run gnome-terminal…

And then you’re going to get someone using Konsole.

What are you trying to do?

James.

¹There’s no accounting for taste…

-- 
E-mail: james@ | I must refute the rumour that one of our team members
aprilcottage.co.uk | walks on water. Although it’s true that Barry Cryer runs
   | on lager...
   | -- “I’m Sorry, I Haven’t A Clue”, BBC Radio 4
-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines


Re: how to know if I'm using xterm or gnome-terminal?

2010-02-23 Thread A. Racca
On Tue, 2010-02-23 at 12:15 -0800, Paolo Galtieri wrote:
 Run
 
 ps axlw | grep term
 
 This will show you which one you are running
 
 Paolo

But if there are several xterms and gnome-terminals running, I'll get
them all. Which I want to know is the one I'm using.

Germán.

 On Tue, Feb 23, 2010 at 11:52 AM, Germán A. Racca
 german.ra...@gmail.com wrote:
 Hi all:
 
 How to know if I'm using an xterm or a gnome-terminal from
 command line?
 
 The output of echo $TERM is xterm from both of them.
 
 How to know?
 
 Cheers,
 Germán.
 --
 Germán A. Racca
 National Institute for Space Research (INPE)
 São José dos Campos - SP - Brasil
 http://sites.google.com/site/gracca
 http://gracca.wordpress.com 


-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines


Re: how to know if I'm using xterm or gnome-terminal?

2010-02-23 Thread A. Racca
On Tue, 2010-02-23 at 20:23 +, James Wilkinson wrote: 
 Germán A. Racca wrote:
  How to know if I'm using an xterm or a gnome-terminal from command line?
  
  The output of echo $TERM is xterm from both of them.
  
  How to know?
 
 Well, it looks as though gnome-terminal sets $COLORTERM, whereas xterm
 doesn’t. But xterm doesn’t unset it, either, so if you get a user
 starting up a gnome-terminal, thinking “Yuck!”¹ and using that
 gnome-terminal solely to run xterm, then the xterm will inherit the
 $COLORTERM setting.
 
 Xterm has its own $XTERM_ variables, so you could test for those. But
 gnome-terminal doesn’t unset those, either, so you could get a user
 starting up am xterm, thinking “Yuck!”¹ and using that xterm solely to
 run gnome-terminal…
 
 And then you’re going to get someone using Konsole.
 
 What are you trying to do?
 
 James.
 
 ¹There’s no accounting for taste…
 
 -- 
 E-mail: james@ | I must refute the rumour that one of our team members
 aprilcottage.co.uk | walks on water. Although it’s true that Barry Cryer runs
| on lager...
| -- “I’m Sorry, I Haven’t A Clue”, BBC Radio 4

I'm running a program called IRAF to work with astronomical images, and
it needs to use the graphic capabilities of an xterm, not
gnome-terminal. So, I'm trying to make a very simple script to start
IRAF, but first I have to know if I'm on an xterm (so it enters directly
to IRAF) or a gnome-terminal (in this case the script must open an xterm
before).

Germán.

-- 
Germán A. Racca
National Institute for Space Research (INPE)
São José dos Campos - SP - Brasil
http://sites.google.com/site/gracca
http://gracca.wordpress.com

-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines


Re: how to know if I'm using xterm or gnome-terminal?

2010-02-23 Thread Jake Peavy
On Tue, Feb 23, 2010 at 3:38 PM, Germán A. Racca german.ra...@gmail.comwrote:

 I'm running a program called IRAF to work with astronomical images, and
 it needs to use the graphic capabilities of an xterm, not
 gnome-terminal. So, I'm trying to make a very simple script to start
 IRAF, but first I have to know if I'm on an xterm (so it enters directly
 to IRAF) or a gnome-terminal (in this case the script must open an xterm
 before).


This must be too easy, but I'm going to say it anyway.  Why not always start
xterm and run IRAF within it?

-- 
-jp

If you were a pirate, you know what would be the one thing that would really
make you mad? Treasure chests with no handles. How the heck are you supposed
to carry it?!

deepthoughtsbyjackhandey.com
-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines


Re: how to know if I'm using xterm or gnome-terminal?

2010-02-23 Thread A. Racca
On Tue, 2010-02-23 at 17:06 -0500, Jake Peavy wrote: 
 On Tue, Feb 23, 2010 at 3:38 PM, Germán A. Racca
 german.ra...@gmail.com wrote:
 I'm running a program called IRAF to work with astronomical
 images, and
 it needs to use the graphic capabilities of an xterm, not
 gnome-terminal. So, I'm trying to make a very simple script to
 start
 IRAF, but first I have to know if I'm on an xterm (so it
 enters directly
 to IRAF) or a gnome-terminal (in this case the script must
 open an xterm
 before). 
 
 This must be too easy, but I'm going to say it anyway.  Why not always
 start xterm and run IRAF within it?
 
 -- 
 -jp

Yes, I can always do that, but I want to make the script also ;-)

G.

-- 
Germán A. Racca
National Institute for Space Research (INPE)
São José dos Campos - SP - Brasil
http://sites.google.com/site/gracca
http://gracca.wordpress.com

-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines


Re: how to know if I'm using xterm or gnome-terminal?

2010-02-23 Thread birger
On Tue, 2010-02-23 at 19:07 -0300, Germán A. Racca wrote:
 On Tue, 2010-02-23 at 17:06 -0500, Jake Peavy wrote: 
  On Tue, Feb 23, 2010 at 3:38 PM, Germán A. Racca
  german.ra...@gmail.com wrote:
  I'm running a program called IRAF to work with astronomical
  images, and
  it needs to use the graphic capabilities of an xterm, not
  gnome-terminal. So, I'm trying to make a very simple script to
  start
  IRAF, but first I have to know if I'm on an xterm (so it
  enters directly
  to IRAF) or a gnome-terminal (in this case the script must
  open an xterm
  before). 

ppid=`grep ^PPid: /proc/$$/status | sed -e s/^PPid:[\t ]*//`
name=`grep ^Name: /proc/$ppid/status | sed -e s/^Name:[\t ]*//`

echo $name

Of course there are still potential errors. The parent of the shell may
not be the terminal. You could check, and if the parent is xterm run in
the terminal. if it is anything else, start it in a new xterm. You will
then get a new xterm if people are logged in remotely or escaping out
from some other app. Perhaps you can live with that?

birger


-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines


Re: how to know if I'm using xterm or gnome-terminal?

2010-02-23 Thread Cameron Simpson
On 23Feb2010 19:07, Germ�n A. Racca german.ra...@gmail.com wrote:
| On Tue, 2010-02-23 at 17:06 -0500, Jake Peavy wrote: 
|  On Tue, Feb 23, 2010 at 3:38 PM, Germán A. Racca
|  german.ra...@gmail.com wrote:
|  I'm running a program called IRAF to work with astronomical
|  images, and
|  it needs to use the graphic capabilities of an xterm, not
|  gnome-terminal.

The Tektronix support stuff? I once had a physical terminal with that
stuff; regrettably it cooked one night:-(

|  So, I'm trying to make a very simple script to
|  start
|  IRAF, but first I have to know if I'm on an xterm (so it
|  enters directly
|  to IRAF) or a gnome-terminal (in this case the script must
|  open an xterm
|  before). 
|  
|  This must be too easy, but I'm going to say it anyway.  Why not always
|  start xterm and run IRAF within it?
| 
| Yes, I can always do that, but I want to make the script also ;-)

Have the script start the xterm:

  : ${have_xterm:=}
  [ -n $have_xterm ] || exec env have_xterm=1 xterm -e $0 ${1+$@}

Self starts in an xterm. Untested.

Cheers,
-- 
Cameron Simpson c...@zip.com.au DoD#743
http://www.cskk.ezoshosting.com/cs/

Being on a Beemer and not having a wave returned by a Sportster is like
having a clipper ship's hailing not returned by an orphaned New Jersey
solid waste barge.   - OTL
-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines


Re: how to know if I'm using xterm or gnome-terminal?

2010-02-23 Thread Justin Willmert
On 2/23/2010 2:38 PM, Germán A. Racca wrote:
 On Tue, 2010-02-23 at 20:23 +, James Wilkinson wrote:

 Germán A. Racca wrote:

 How to know if I'm using an xterm or a gnome-terminal from command line?

 The output of echo $TERM is xterm from both of them.

 How to know?

 I'm running a program called IRAF to work with astronomical images, and
 it needs to use the graphic capabilities of an xterm, not
 gnome-terminal. So, I'm trying to make a very simple script to start
 IRAF, but first I have to know if I'm on an xterm (so it enters directly
 to IRAF) or a gnome-terminal (in this case the script must open an xterm
 before).

 Germán.

What about something like this in your script?

 PARENTPID=$(ps -o ppid -p $PPID | tail -n1)
 ps u -p $PARENTPID | grep xterm  { echo Yes!; } || { echo no; }

The first line gets the parent of your script's parent process (so 
bash's parent). Then the second line prints out the information based on 
that pid, which is what you're testing against.

If there are more levels in between, this doesn't work the way it is, 
but you should be able to easily scale it to a loop which keeps going 
either until it hits an xterm process or hits init (as a last resort. 
Maybe there are better conditions you could figure out).

Justin Willmert
-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines