Re: list of running X11 applications...
Re: list of running X11 applications...
- Subject: Re: list of running X11 applications...
- From: Ronnie Misra <email@hidden>
- Date: Mon, 7 Jul 2003 10:43:54 -0700
On Saturday, July 5, 2003, at 12:01AM, John Davidorff Pell wrote:
Is there a way for me to get a list of running applications from the X
server? I'm not a programmer (I'm learning) so telling me about
function calls won't help me too much (but if that's all there is then
I'll use that as my focus to learn. :-)) Are there and CLI utils or
options to the X server to get it to tell me?
thanx in advance, JP
Another way is to use the "lsof" command. X11 clients can connect to
the server either through a Unix socket or on a tcp port. "lsof -U"
will list active Unix socket connections, and lsof -itcp:x11 will list
active connections involving the X11 tcp port. I hacked up the
following perl script to parse the output from those commands.
--- BEGIN ---
#!/usr/bin/perl
use strict;
my (@x, %p, %r);
open F, "lsof -U |";
while(<F>) {
my @p = split(/\s+/, $_);
if ($p[0] eq "Xquartz") { push @x, $p[5]; }
$p{$p[7]} = \@p;
}
foreach my $x (@x) {
if ($p{"->$x"}) {
my @p = @{$p{"->$x"}};
$r{$p[1]} = $p[0];
}
}
open F, "lsof -itcp:x11 | tail +2 |";
while(<F>) {
my @p = split(/\s+/, $_);
$r{$p[1]} = $p[0];
}
foreach my $r (sort {$a <=> $b} (keys %r)) {
print "$r\t$r{$r}\n";
}
--- END ---
Note that it will not list direct connections from remote hosts (if you
directly set DISPLAY on the remote host), and it will list all clients
running over an ssh session simply as "ssh".
Ronnie
_______________________________________________
x11-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/x11-users
X11 for Mac OS X FAQ: http://developer.apple.com/qa/qa2001/qa1232.html
Report issues, request features, feedback: http://developer.apple.com/bugreporter
Do not post admin requests to the list. They will be ignored.