use strict; use warnings; eval { use X11::Protocol; # Screen dimensions my $x11 = X11::Protocol->new (); my $screen = ($ENV{DISPLAY}//":0.0") =~ m/\.(\d+)$/ ? $1 : 0; $x11->choose_screen ($screen); # Root window printf "Screen is %4d x %4d x %2d pixels (%3d x %3d mm) (X11)\n", $x11->{width_in_pixels}, $x11->{height_in_pixels}, $x11->{root_depth}, $x11->{width_in_millimeters}, $x11->{height_in_millimeters}; }; eval { use Tk; my $mw = Tk::MainWindow->new; printf "Screen is %4d x %4d x %2d pixels (%3d x %3d mm) (Tk)\n", $mw->screenwidth, $mw->screenheight, $mw->depth, $mw->screenmmwidth, $mw->screenmmheight; };