#!/usr/bin/perl -w use strict; use lib `fvwm-perllib dir`; use FVWM::Module; use IO::File; my $run_xmessage = 0; my $module = new FVWM::Module( Name => "FvwmPerlBasedWinList", Mask => M_WINDOW_NAME | M_END_WINDOWLIST, EnableOptions => { "x" => \$run_xmessage }, ); my $fh = $run_xmessage ? new IO::File "| xmessage -geometry 240x300 -title 'Window List' -file -" : \*STDERR; # Register the event handlers $module->add_handler(M_WINDOW_NAME, sub { my ($self, $event) = @_; printf $fh " 0x%07lx | %s\n", $event->_win_id, $event->_name; }); # This one signals that the module should be terminated $module->add_handler(M_END_WINDOWLIST, sub { print $fh "-----------+--------------------\n"; close $fh; $module->terminate; }); print $fh "-----------+--------------------\n"; print $fh " Window id | Name\n"; print $fh "-----------+--------------------\n"; # Ask fvwm to send us its list of windows $module->send("Send_WindowList"); # Enter the main loop $module->event_loop;