[Perl]Modules From Scratch: updating examples

User avatar
Posts: 85
Joined: Thu Jul 12, 2007 3:54 am

[Perl]Modules From Scratch: updating examples

Postby mimosinnet » Sat May 11, 2013 3:16 pm

There is this excellent tutorial on how to write Perl Fvwm modules from scratch. Although perfectly documented in the man page (execute fvwm-perllib cat FVWM::Module in your terminal), there are some minor changes in the syntax that may confuse a newcomer to Perl Modules (like me) if using information from some older web pages. This is the example given in the first post with up-to-date syntax (fvwm-2.6.5):

Code: Select all

#!/usr/bin/env perl

use strict;
use warnings;

use lib `fvwm-perllib dir`;
use FVWM::Module;
use FVWM::EventNames;

my $module = FVWM::Module->new(
    Mask    => M_STRING,
    Debug   => 1,

# a bit of chatter to show its working
# (this is shown in .xsession-errors or the file you have set-up
# with, for example, 'fvwm 2> .fvwm-errors' in .xinitrc )
$module->show_message("FvwmRingMenu starting up");

# add a handler for string events - this is the SendToModule event
   M_STRING, sub {
       my $mod = shift;
       my $event = shift;
      my $text  = $event->{ arg_values }[3];
      $mod->show_message( "Message Received: " . $text );


The path where the module is located has to be included in your config file like, for example:

Code: Select all

ModulePath $HOME/.fvwm/Modules:+

In a FvwmConsole, writing:

Code: Select all

Module FvwmRingMenu

Echoes in .xsession-errors (or equivalent file):

Code: Select all

[FvwmRingMenu]: FvwmRingMenu starting up

Afterwards, writing in the FvwmConsole:

Code: Select all

SendToModule FvwmRingMenu 12321

You get in .xsession-erros:

Code: Select all

[FvwmRingMenu]: Message Received: 12321

Hope this is helpful.

Return to “Other languages”

Who is online

Users browsing this forum: No registered users and 1 guest