in reply to How to get the width of a console window?

If you are in X, you can get it from xwininfo. Also if in X, the X11::Protocol module may help.

Here are a couple of other snippets which may( or may not :-) ) work for you :

#!/usr/bin/perl use Term::ReadKey; ($wchar, $hchar, $wpixels, $hpixels) = GetTerminalSize(); print "$wchar\t$hchar\t$wpixels\t$hpixels\n";
#!/usr/bin/perl @x = qx(stty -a); @y = split(/;/, $x[0]); print "screen size is $y[1] $y[2]\n"; ########################################### #Also, you can specify 'size' to avoid parsing; ($rows, $cols) = split ' ', qx"stty size </dev/tty 2>/dev/null"; print "screen size is $rows x $cols\n";

I'm not really a human, but I play one on earth. flash japh

Replies are listed 'Best First'.
Re^2: How to get the width of a console window?
by bmcatt (Friar) on Jun 07, 2004 at 16:33 UTC
    I was just thinking that the information should be available from stty, and was trying to figure out how to parse the output from stty, having forgotten about stty size.

    Good on you, zentara++