File: getxtitle

package info (click to toggle)
splitvt 1.6.5-0potato1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 332 kB
  • ctags: 399
  • sloc: ansic: 4,684; sh: 78; makefile: 55; perl: 15
file content (20 lines) | stat: -rwxr-xr-x 380 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/perl
#
# This is a script to return the current title of an xterm.

if ( ! $ARGV[0] ) {
	if ( ! $ENV{'WINDOWID'} ) {
		die "Not running under an xterm.\n";
	}
	$ARGV[0]=$ENV{'WINDOWID'};
}
open(PIPE, "xprop -id $ARGV[0] |") || die "Can't run xprop: $!\n";

while ( <PIPE> ) {
	chop;
	if ( /WM_NAME\(STRING\) = \"([^\"]*)\"/ ) {
		print "$1\n";
		exit(0);
	}
}
exit(1);