Restructure how we look for Read files slightly.
[fvwm.git] / tests / perl / module-winlist
blob3c0df5b40f52ea59aa11175ae5cb2fdc17b921c1
1 #!/usr/bin/perl -w
3 use strict;
4 use lib `fvwm-perllib dir`;
5 use FVWM::Module;
6 use IO::File;
8 my $run_xmessage = 0;
9 my $module = new FVWM::Module(
10 Name => "FvwmPerlBasedWinList",
11 Mask => M_WINDOW_NAME | M_END_WINDOWLIST,
12 EnableOptions => { "x" => \$run_xmessage },
14 my $fh = $run_xmessage
15 ? new IO::File "| xmessage -geometry 240x300 -title 'Window List' -file -"
16 : \*STDERR;
18 # Register the event handlers
19 $module->add_handler(M_WINDOW_NAME, sub {
20 my ($self, $event) = @_;
21 printf $fh " 0x%07lx | %s\n", $event->_win_id, $event->_name;
22 });
24 # This one signals that the module should be terminated
25 $module->add_handler(M_END_WINDOWLIST, sub {
26 print $fh "-----------+--------------------\n";
27 close $fh;
28 $module->terminate;
29 });
31 print $fh "-----------+--------------------\n";
32 print $fh " Window id | Name\n";
33 print $fh "-----------+--------------------\n";
35 # Ask fvwm to send us its list of windows
36 $module->send("Send_WindowList");
38 # Enter the main loop
39 $module->event_loop;