From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17124 invoked from network); 4 Dec 2004 22:55:10 +0000 Received: from smtp.gentoo.org (156.56.111.197) by lists.gentoo.org with AES256-SHA encrypted SMTP; 4 Dec 2004 22:55:10 +0000 Received: from lists.gentoo.org ([156.56.111.196] helo=parrot.gentoo.org) by smtp.gentoo.org with esmtp (Exim 4.41) id 1Caio2-00027D-Gy for arch-gentoo-user@lists.gentoo.org; Sat, 04 Dec 2004 22:55:10 +0000 Received: (qmail 1051 invoked by uid 89); 4 Dec 2004 22:54:54 +0000 Mailing-List: contact gentoo-user-help@gentoo.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail Reply-To: gentoo-user@lists.gentoo.org X-BeenThere: gentoo-user@gentoo.org Received: (qmail 1642 invoked from network); 4 Dec 2004 22:54:53 +0000 Message-ID: <41B24037.1050901@ramshacklestudios.com> Date: Sat, 04 Dec 2004 14:54:47 -0800 From: Peter Gordon User-Agent: Mozilla Thunderbird 1.0RC1 (X11/20041201) X-Accept-Language: en-us, en MIME-Version: 1.0 To: gentoo-user@lists.gentoo.org References: <9acccfe5041204133432d7a3e@mail.gmail.com> In-Reply-To: <9acccfe5041204133432d7a3e@mail.gmail.com> X-Enigmail-Version: 0.89.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server.e3-kracken.com X-AntiAbuse: Original Domain - lists.gentoo.org X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [26 6] X-AntiAbuse: Sender Address Domain - ramshacklestudios.com X-Source: X-Source-Args: X-Source-Dir: Subject: Re: [gentoo-user] Can a script tell if it's running under X? X-Archives-Salt: 9eced00a-9326-4f03-b012-98cf4b5ff4eb X-Archives-Hash: 9c0a858bf0d43c96b3230967e76d5dd1 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Kevin O'Gorman wrote: | Is there a way for a script (bash, for instance) to know | if it's running under X, such as in an xterm or konsole? | | I want to have scripts that run graphical tools if the | infrastructure is present, and text tools otherwise. | For me this is particularly useful for tools I don't use | all that often, and can forget that a graphical version | exists. One way to do it (though I don't know how to do this in Bash) is to check X's Process ID (PID). If `pidof X` returns an integer, than that's the PID of the currently running X server. If X is not running it will return an empty string. /home/peter $ pidof X 12521 /home/peter $ pidof non-running-app /home/peter $ Hope this helps! - -- () The ASCII Ribbon Campaign - against HTML Email, /\ vCards, and proprietary formats. - --------------------------------------------------- Peter A. Gordon (codergeek42) E-Mail: admin@ramshacklestudios.com GPG Public Key ID: 0x109DBECE GPG Key Fingerprint (SHA1): ~ E485 E2F7 11CE F9B2 E3D9 C95D 208F B732 109D BECE Encrypted and/or Signed correspondence preffered. - --------------------------------------------------- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFBskA1II+3MhCdvs4RAjCOAKCzApn5hQ6w0yor2JMp2xASs8BzeQCgkUyp 5Yi1b6GIKNHVR2QYEwIFfEE= =9Wp6 -----END PGP SIGNATURE----- -- gentoo-user@gentoo.org mailing list