summaryrefslogtreecommitdiff
path: root/app/fvwm/modules/FvwmEvent
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2006-11-26 10:53:58 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2006-11-26 10:53:58 +0000
commit1cb4778bcef21ea9015cfccdb99abb7a0e035d74 (patch)
treef164009397f9d3d5634c6f8a94b1542f793d9692 /app/fvwm/modules/FvwmEvent
parent841f8331c93ff96bd798e9a74ba10fab155da5c5 (diff)
Importing from XF4, plus BSD make infrastructure
Diffstat (limited to 'app/fvwm/modules/FvwmEvent')
-rw-r--r--app/fvwm/modules/FvwmEvent/ChangeLog26
-rw-r--r--app/fvwm/modules/FvwmEvent/FvwmEvent.1251
-rw-r--r--app/fvwm/modules/FvwmEvent/FvwmEvent.c519
-rw-r--r--app/fvwm/modules/FvwmEvent/Imakefile6
4 files changed, 802 insertions, 0 deletions
diff --git a/app/fvwm/modules/FvwmEvent/ChangeLog b/app/fvwm/modules/FvwmEvent/ChangeLog
new file mode 100644
index 000000000..3141c918a
--- /dev/null
+++ b/app/fvwm/modules/FvwmEvent/ChangeLog
@@ -0,0 +1,26 @@
+1999-01-08 Paul D. Smith <psmith@gnu.org>
+
+ * FvwmEvent.c (main): Remove USE_POSIX/USE_BSD stuff and rely on
+ HAVE_SIGACTION to choose between new- and old-style signal
+ handling.
+ (TerminateHandler): Use the autoconf'd return type for signal
+ handlers.
+
+1998-12-17 Dominik Vogt <dominik_vogt@hp.com>
+
+ * Parse.c (PeekArgument): malloc -> safemalloc
+
+1998-11-24 Paul D. Smith <psmith@gnu.org>
+
+ * Parse.h (LFindToken): Remove this macro. It's not used, and it
+ uses a non-standard function lfind(). Best to not use it at all.
+ (search.h): Removed #include.
+
+Tue Nov 10 22:20:21 1998 DanEspen <dje@blue>
+
+ * FvwmEvent.c (config): Fix logic on test for cmd needs a
+ parameter. Thes test for "table != e" was incorrect. Only try to
+ strip off trailing newline when there is a newline on the command.
+ It was stripping the last character when commands came in from
+ FvwmTalk.
+
diff --git a/app/fvwm/modules/FvwmEvent/FvwmEvent.1 b/app/fvwm/modules/FvwmEvent/FvwmEvent.1
new file mode 100644
index 000000000..39a6f193d
--- /dev/null
+++ b/app/fvwm/modules/FvwmEvent/FvwmEvent.1
@@ -0,0 +1,251 @@
+.\" t
+.\" @(#)FvwmEvent.1 3/28/94
+.TH FvwmEvent 1.0 "Apr 22 1998"
+.UC
+.SH NAME
+\fBFvwmEvent\fP \- the FVWM Event module
+.SH SYNOPSIS
+\fBFvwmEvent\fP is a more versatile replacement for \fBFvwmAudio\fP.
+It can in general be used to hook any \fBfvwm2\fP function or program to any
+window manager event. e.g: Delete unwanted netscape-popups or
+application error popups as they appear, play sounds, log events to a
+file and the like. Be creative, You'll find a use for it.
+
+\fBFvwmEvent\fP is spawned by \fBfvwm2(1)\fP, so no command line invocation will
+work. From within the \fI.fvwm2rc\fP file, \fBFvwmEvent\fP is spawned as
+follows:
+.nf
+.sp
+Module FvwmEvent
+.sp
+.fi
+or from within an \fBfvwm2\fP pop-up menu:
+.nf
+.sp
+DestroyMenu Module-Popup
+AddToMenu Module-Popup "Modules" Title
++ "Event" Module FvwmEvent
++ "Auto" Module FvwmAuto 200
++ "Buttons" Module FvwmButtons
++ "Ident" Module FvwmIdent
++ "Banner" Module FvwmBanner
++ "Pager" Module FvwmPager 0 3
+.sp
+.fi
+.SH DESCRIPTION
+The \fBFvwmEvent\fP module communicates with the \fBfvwm2\fP window manager
+to bind \fIactions\fP to window manager \fIevents\fP. Different actions
+may be assigned to distinct window manager events.
+
+\fBFvwmEvent\fP can be used to bind sound files to events like
+\fBFvwmAudio\fP (RiP) did. It can be used for logging event traces to
+a log file, while debugging \fBfvwm2\fP.
+
+\fBFvwmEvent\fP can also have builtin support for the rplay library.
+(heritage of FvwmAudio)
+
+.SH CONFIGURATION OPTIONS
+\fBFvwmEvent\fP reads the same \fI.fvwm2rc\fP file as \fBfvwm2\fP
+reads when it starts up, and looks for certain configuration options:
+
+.IP "*FvwmEventCmd \fIcommand\fP"
+This determines the \fBfvwm2\fP function that is to be called with the
+event parameters.
+You might want to do one of the following (details below):
+.nf
+.sp
+ *FvwmEventCmd \fIbuiltin-rplay\fP
+ play sounds
+ *FvwmEventCmd
+ execute distinct fvwm2 functions
+ *FvwmEventCmd exec
+ execute distinct external programs
+.sp
+.fi
+This version of \fBFvwmEvent\fP has builtin \fBrplay\fP support which does not
+need to invoke an external audio player to play sounds. The rplay
+support is enabled when \fBFvwmEvent\fP is compiled with \fIHAVE_RPLAY\fP defined
+(see the Imakefile) and when \fBFvwmEventCmd\fP is set to \fIbuiltin-rplay\fP.
+
+For example:
+.nf
+.sp
+ *FvwmEventCmd \fIbuiltin-rplay\fP
+ *FvwmEvent add_window drip.au
+
+rplay can be obtained via anonymous ftp at
+ <URL:ftp://ftp.sdsu.edu/pub/rplay>
+or <URL:ftp://ftp.x.org/contrib/Event/rplay>
+.sp
+.fi
+\fBFvwmEvent\fP also has support for any other external program.
+e.g: the rsynth 'say' command:
+.nf
+.sp
+ *FvwmEventCmd /rsynth/say
+ *FvwmEvent destroy_window "window closed"
+.sp
+.fi
+You can also use \fBfvwm2\fP's builtin \fIEcho\fP command as
+\fIFvwmEventCmd\fP to obtain debug output for \fBfvwm2\fP events quietly.
+I used this setup to debug FvwmAuto:
+.nf
+.sp
+ *FvwmEventCmd \fIEcho\fP
+ *FvwmEvent focus_change "focus change"
+ *FvwmEvent raise_window "raise window"
+.sp
+.fi
+You can even call different shell commands for each event just by setting
+.nf
+.sp
+ *FvwmEventCmd exec
+ *FvwmEvent add_window killname "APPL ERROR"
+.sp
+.fi
+.IP "*FvwmEvent \fIwindow-manager-event action-or-filename\fP"
+Binds particular actions to window manager events.
+.nf
+.sp
+e.g. for audio-events:
+
+ *FvwmEvent startup TaDa.au
+ *FvwmEvent shutdown Elvis_Left.au
+ *FvwmEvent unknown doh.au
+
+ *FvwmEvent new_page beam_trek.au
+ *FvwmEvent new_desk beam_trek.au
+ *FvwmEvent add_window drip.au
+ *FvwmEvent raise_window swoosh.au
+ *FvwmEvent lower_window swoosh.au
+ *FvwmEvent configure_window hammer.au
+ *FvwmEvent focus_change boing.au
+ *FvwmEvent destroy_window explosion.au
+ *FvwmEvent iconify ploop.au
+ *FvwmEvent deiconify ploop.au
+ *FvwmEvent window_name huh.au
+ *FvwmEvent icon_name beep.au
+ *FvwmEvent res_class beep.au
+ *FvwmEvent res_name beep.au
+ *FvwmEvent end_windowlist twang.au
+
+ *FvwmEvent icon_location beep.au
+ *FvwmEvent map beep.au
+ *FvwmEvent error beep.au
+ *FvwmEvent config_info beep.au
+ *FvwmEvent end_config_info beep.au
+ *FvwmEvent icon_file beep.au
+ *FvwmEvent default_icon beep.au
+ *FvwmEvent string plapper.au
+
+ *FvwmEvent mini_icon beep.au
+ *FvwmEvent windowshade beep.au
+ *FvwmEvent dewindowshade beep.au
+.sp
+.fi
+Provided \fBfvwm2\fP supports it (not yet), there's an additional event to
+replace all \fBfvwm2\fP beeps with a sound:
+.nf
+.sp
+ *FvwmEvent beep beep.au
+.sp
+.fi
+The toggle_paging event will be supported, as soon, as it's
+resurrected by \fBfvwm2\fP:
+.nf
+.sp
+ *FvwmEvent toggle_paging fwop.au
+.sp
+.fi
+.IP "*FvwmEventDelay \fI5\fP"
+Specifies that an event-action will only be executed if it occurs at
+least 5 seconds after the previous event. Events that occur during
+the delay period are ignored. This option is useful if you don't want
+several sounds playing at the same time. The default delay is 0 which
+disables the Event delay.
+
+
+.SH RPLAY OPTIONS
+The following options are only valid with builtin rplay support.
+i.e: when \fBFvwmEvent\fP was compiled with \fIHAVE_RPLAY\fP defined
+(see the Imakefile). They are used only if \fBFvwmEventCmd\fP is set
+to \fIbuiltin-rplay\fP.
+
+
+.IP "*FvwmEventRplayHost \fIhostname\fP"
+Specifies what host the rplay sounds will play on. The \fIhostname\fP
+can also be an environment variable such as $HOSTDISPLAY.
+
+.IP "*FvwmEventRplayPriority \fI0\fP"
+Specifies what priority will be assigned to the rplay sounds when they
+are played.
+
+.IP "*FvwmEventRplayVolume \fI127\fP"
+Specifies what volume will be assigned to the sounds when they are
+played.
+
+.SH INVOCATION
+The invocation method was shown in the synopsis section. No command
+line invocation is possible. \fBFvwmEvent\fP must be invoked by the
+\fBfvwm2\fP window manager.
+.sp
+
+.SH FvwmAudio Compatibility
+
+FvwmAudioPlayCmd used to call an external program.
+FvwmEventCmd calls an \fBfvwm2\fP function. External programs can be called
+using the \fBfvwm2\fP exec function "exec program".
+
+FvwmAudioDir has been removed due to the fact that the parameters
+don't have to be files any more.
+use:
+.nf
+.sp
+ DestroyFunc mysay
+ AddToFunc mysay "I" exec /rsynth/say /rsynth/audiofiles/$1
+
+ *FvwmEventCmd mysay
+.sp
+.fi
+.SH BUGS
+It's REALLY noisy when \fBfvwm2\fP starts and restarts using an audio player.
+FvwmEventDelay helps a little bit.
+
+The parameters inherent to several events are not accessible. This
+might be implemented in the future so that the command executed by
+fvwm2 looks like FvwmEventCmd FvwmEvent-parameters
+event-specific-parameters.
+
+Simple \fBFvwmAuto\fP could then be emulated by:
+.nf
+ *FvwmEventCmd
+ *FvwmEvent raise-window Raise
+.sp
+.fi
+.SH COPYRIGHTS
+This module has evolved of \fBFvwmAudio\fP, which in term is heavily based
+on a similar Fvwm module called \fBFvwmSound\fP by Mark
+Boyns. \fBFvwmAudio\fP simply took Mark's original program and
+extended it to make it generic enough to work with any Audio
+player. Due to different requests to do specific things on specific events,
+\fBFvwmEvent\fP took this one step further and now calls any
+\fBfvwm2\fP function, or builtin-rplay. If \fBfvwm2\fP's Exec function
+is used, any external program can be called with any parameter.
+
+The concept for interfacing this module to the Window Manager, is
+original work by Robert Nation.
+
+Copyright 1998 Albrecht Kadlec.
+Copyright 1994, Mark Boyns and Mark Scott. No guarantees or
+warranties or anything are provided or implied in any way whatsoever.
+Use this program at your own risk. Permission to use and modify this
+program for any purpose is given, as long as the copyright is kept intact.
+
+
+.sp
+.SH AUTHORS
+.nf
+1994 FvwmSound Mark Boyns (\fIboyns@sdsu.edu\fP)
+1994 FvwmAudio Mark Scott (\fImscott@mcd.mot.com\fP)
+1996 FvwmAudio Albrecht Kadlec
+1998 FvwmEvent Albrecht Kadlec (\fIalbrecht@auto.tuwien.ac.at\fP)
diff --git a/app/fvwm/modules/FvwmEvent/FvwmEvent.c b/app/fvwm/modules/FvwmEvent/FvwmEvent.c
new file mode 100644
index 000000000..661c988ce
--- /dev/null
+++ b/app/fvwm/modules/FvwmEvent/FvwmEvent.c
@@ -0,0 +1,519 @@
+/*#define DEBUG
+ *
+ * Copyright (C) 1994 Mark Boyns (boyns@sdsu.edu) and
+ * Mark Scott (mscott@mcd.mot.com)
+ * 1996-1998 Albrecht Kadlec (albrecht@auto.tuwien.ac.at)
+ *
+ * FvwmEvent version 1.0
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+/* ChangeLog
+
+ * renamed & cleaned up so that FvwmEvent (TaDa !!) is a general event
+ handler module.
+ -- 21.04.98 Albrecht Kadlec (albrecht@auto.tuwien.ac.at)
+
+ * changed parsing to use new library functions
+
+ * merged bug fix from Christophe MARTIN <cmartin@ipnl.in2p3.fr>
+ - FvwmAudio doesn't read messages it is not interrested in,
+ thus desynchronize,
+ - keep time stamp even if no sound is played
+ - minimize malloc/free
+
+ mark boyns ok-ed this patch, I reviewed it and put out those ugly
+ #defines for RESYNC and READ_BODY by reordering the control structures
+ -- Albrecht Kadlec (albrecht@auto.tuwien.ac.at)
+
+ * made FvwmAudio insensitive to its name -> can be symlinked.
+ corrected some error message deficiencies, code for quoted 'sound'
+ parameters shamelessly stolen from FvwmButtons/parse.c (with minimal
+ adjustments)
+ FvwmAudio now supports rsynth's say command:
+ *FvwmAudioPlayCmd say
+ *FvwmAudio add_window "add window"
+ *FvwmAudio raise_window 'raise window'
+ -- 08/07/96 Albrecht Kadlec (albrecht@auto.tuwien.ac.at)
+
+ * Fixed FvwmAudio to reflect the changes made to the module protocol.
+
+ * Szijarto Szabolcs <saby@sch.bme.hu> provided FvwmSound code that used
+ $HOSTDISPLAY for the rplay host. The code has been added to FvwmAudio.
+
+ * Fixed bugs reported by beta testers, thanks!
+
+ * Builtin rplay support has been added to FvwmAudio. This support is
+ enabled when FvwmAudio is compiled with HAVE_RPLAY defined and when
+ FvwmAudioPlayCmd is set to builtin-rplay. I guess it's safe to say
+ that FvwmSound is now obsolete. -- Mark Boyns 5/7/94
+
+ * FvwmAudio is based heavily on an Fvwm module "FvwmSound" by Mark Boyns
+ and the real credit for this really goes to him for the concept.
+ I just stripped out the "rplay" library dependencies to allow generic
+ audio play command support.
+
+ */
+
+/*
+ * This module is based on FvwmModuleDebugger which has the following
+ * copyright:
+ *
+ * This module, and the entire ModuleDebugger program, and the concept for
+ * interfacing this module to the Window Manager, are all original work
+ * by Robert Nation
+ *
+ * Copyright 1994, Robert Nation. No guarantees or warantees or anything
+ * are provided or implied in any way whatsoever. Use this program at your
+ * own risk. Permission to use this program for any purpose is given,
+ * as long as the copyright is kept intact.
+ */
+
+#include "config.h"
+#include "../../fvwm/module.h"
+#include "fvwmlib.h"
+
+/*
+ * fvwm includes:
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/wait.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <ctype.h>
+
+/*
+ * rplay includes:
+ */
+#ifdef HAVE_RPLAY
+#include <rplay.h>
+#undef M_ERROR /* Solaris fix */
+#endif
+
+#include "ModParse.h"
+
+#ifdef DEBUG
+#define INFO(x) fprintf(stderr,x)
+#else
+#define INFO(x)
+#endif
+
+#define BUILTIN_STARTUP MAX_MESSAGES
+#define BUILTIN_SHUTDOWN MAX_MESSAGES+1
+#define BUILTIN_UNKNOWN MAX_MESSAGES+2
+#define MAX_BUILTIN 3
+
+#define BUFSIZE 512
+
+/* globals */
+char *MyName;
+int MyNameLen;
+int fd[2];
+char cmd_line[BUFSIZE]="";
+time_t audio_delay = 0, /* seconds */
+ last_time = 0,
+ now;
+
+#ifdef HAVE_RPLAY
+int rplay_fd = -1;
+#endif
+
+/* prototypes */
+int execute_event(short);
+void config(void);
+void DeadPipe(int) __attribute__((__noreturn__));
+
+static RETSIGTYPE TerminateHandler(int);
+
+/* define the event table */
+char *events[MAX_MESSAGES+MAX_BUILTIN] =
+{
+ "new_page",
+ "new_desk",
+ "add_window",
+ "raise_window",
+ "lower_window",
+ "configure_window",
+ "focus_change",
+ "destroy_window",
+ "iconify",
+ "deiconify",
+ "window_name",
+ "icon_name",
+ "res_class",
+ "res_name",
+ "end_windowlist",
+ "icon_location",
+ "map",
+ "error",
+ "config_info",
+ "end_config_info",
+ "icon_file",
+ "default_icon",
+ "string",
+#ifdef M_BELL
+ "beep",
+#endif
+#ifdef M_TOGGLEPAGE
+ "togglepage",
+#endif
+ "mini_icon",
+ "windowshade",
+ "dewindowshade",
+ "locksonsend",
+ "sendconfig",
+/* add builtins here */
+ "startup",
+ "shutdown",
+ "unknown"
+};
+
+/* define the action table */
+char *action_table[MAX_MESSAGES+MAX_BUILTIN];
+
+#ifdef HAVE_RPLAY
+/* define the rplay table */
+RPLAY *rplay_table[MAX_MESSAGES+MAX_BUILTIN];
+#endif
+
+static volatile sig_atomic_t isTerminated = False;
+
+int main(int argc, char **argv)
+{
+ char *s;
+ unsigned long header[HEADER_SIZE], body[MAX_BODY_SIZE];
+ int total, remaining, count, event;
+
+INFO("--- started ----\n");
+
+ /* Save our program name - for error events */
+
+ if ((s=strrchr(argv[0], '/'))) /* strip path */
+ s++;
+ else /* no slash */
+ s = argv[0];
+
+ MyNameLen=strlen(s)+1; /* account for '*' */
+ MyName = safemalloc(MyNameLen+1); /* account for \0 */
+ *MyName='*';
+ strcpy(MyName+1, s); /* append name */
+
+ if ((argc != 6)&&(argc != 7)) /* Now MyName is defined */
+ {
+ fprintf(stderr,"%s Version "VERSION" should only be executed by fvwm!\n",
+ MyName+1);
+ exit(1);
+ }
+
+ INFO("--- installing signal server\n");
+
+#ifdef HAVE_SIGACTION
+ {
+ struct sigaction sigact;
+
+ sigemptyset(&sigact.sa_mask);
+# ifdef SA_INTERRUPT
+ sigact.sa_flags = SA_INTERRUPT;
+# else
+ sigact.sa_flags = 0;
+# endif
+ sigact.sa_handler = TerminateHandler;
+
+ sigaction(SIGPIPE,&sigact,NULL); /* Dead pipe == Fvwm died */
+ sigaction(SIGTERM,&sigact,NULL); /* "polite" termination signal */
+ }
+#else
+ /* We don't have sigaction(), so fall back to less robust methods. */
+ signal(SIGPIPE, TerminateHandler);
+ signal(SIGTERM, TerminateHandler);
+#endif
+
+ fd[0] = atoi(argv[1]);
+ fd[1] = atoi(argv[2]);
+
+INFO("--- configuring\n");
+
+ config(); /* configure events */
+ execute_event(BUILTIN_STARTUP); /* Startup event */
+
+ SendText(fd,"Nop",0); /* what for ? */
+
+
+ /* main loop */
+
+INFO("--- waiting\n");
+ while ( !isTerminated )
+ {
+ if ((count = read(fd[1],header,
+ HEADER_SIZE*sizeof(unsigned long))) <= 0)
+ exit(0);
+/* if this read is interrrupted EINTR, the wrong event is triggered !!! */
+
+ if( header[0] != START_FLAG )
+ continue; /* should find something better for resyncing */
+
+ /* Ignore events that occur during the delay period. */
+ now = time(0);
+
+ /* junk the event body */
+ total=0;
+ remaining = (header[2] - HEADER_SIZE) * sizeof(unsigned long);
+ while (remaining)
+ {
+ if((count=read(fd[1],&body[total],remaining)) < 0)
+ exit(0);
+ remaining -= count;
+ total +=count;
+ }
+
+ if (now < last_time + audio_delay)
+ continue; /* quash event */
+
+ /*
+ * event will equal the number of shifts in the
+ * base-2 header[1] number. Could use log here
+ * but this should be fast enough.
+ */
+ event = -1;
+ while (header[1])
+ {
+ event++;
+ header[1] >>= 1;
+ }
+ if (event < 0 || event >= MAX_MESSAGES)
+ event=BUILTIN_UNKNOWN;
+
+ execute_event(event); /* execute action */
+ } /* while */
+
+ execute_event(BUILTIN_SHUTDOWN);
+ return 0;
+}
+
+
+/***********************************************************************
+ *
+ * Procedure:
+ *
+ * execute_event - actually executes the actions from lookup table
+ *
+ **********************************************************************/
+int execute_event(short event)
+{
+ static char buf[BUFSIZE];
+
+#ifdef HAVE_RPLAY
+ if (rplay_fd != -1) /* this is the sign that rplay is used */
+ {
+ if (rplay_table[event])
+ if (rplay(rplay_fd, rplay_table[event]) >= 0)
+ last_time = now;
+ else
+ rplay_perror("rplay");
+ return 0;
+ } else /* avoid invalid second execute */
+#endif
+ if (action_table[event])
+ {
+ sprintf(buf,"%s %s", cmd_line, action_table[event]);
+#if 1
+INFO(buf);
+INFO("\n");
+
+ SendText(fd,buf,0); /* let fvwm2 execute the function */
+ last_time = now;
+#else
+ if( ! ( ret = system(buf))) /* directly execute external program */
+ last_time = now;
+ return ret;
+#endif
+ }
+ return 1;
+}
+
+
+/***********************************************************************
+ *
+ * Procedure:
+ * config - read the configuration file.
+ *
+ ***********************************************************************/
+
+char *table[]=
+{
+ "Cmd",
+ "Delay"
+#ifdef HAVE_RPLAY
+ ,
+ "RplayHost",
+ "RplayPriority",
+ "RplayVolume"
+#endif
+}; /* define entries here, if this list becomes unsorted, use LFindToken */
+
+
+void config(void)
+{
+ char *buf, *event, *action, *p, *q, **e;
+ int i, found;
+#ifdef HAVE_RPLAY
+ int volume = RPLAY_DEFAULT_VOLUME,
+ priority = RPLAY_DEFAULT_PRIORITY;
+ char host[128];
+
+ strcpy(host, rplay_default_host());
+#endif
+
+ /* Intialize all the actions */
+
+ for (i = 0; i < MAX_MESSAGES+MAX_BUILTIN; i++)
+ {
+ action_table[i] = NULL;
+#ifdef HAVE_RPLAY
+ rplay_table[i] = NULL;
+#endif
+ }
+
+ while (GetConfigLine(fd,&buf), buf != NULL)
+ {
+ if (buf[strlen(buf)-1] == '\n') { /* if line ends with newline */
+ buf[strlen(buf)-1] = '\0'; /* strip off \n */
+ }
+
+ /* Search for MyName (normally *FvwmAudio) */
+ if (strncasecmp(buf, MyName, MyNameLen) == 0)
+ {
+ p = buf+MyNameLen;
+INFO(buf);
+INFO("\n");
+ if ((e= FindToken(p,table,char *))) /* config option ? */
+ {
+ p+=strlen(*e); /* skip matched token */
+ q=GetArgument(&p);
+ if (!q)
+ {
+ fprintf(stderr,"%s: %s%s needs a parameter\n",
+ MyName+1, MyName+1,*e);
+ continue;
+ }
+
+ switch (e - (char**)table)
+ {
+ case 0: if (q) strcpy(cmd_line, q); /* Cmd */
+ else *cmd_line='\0';
+INFO("cmd_line = ->");
+INFO(cmd_line);
+INFO("<-\n");
+ break;
+ case 1: audio_delay = atoi(q); break; /* Delay */
+#ifdef HAVE_RPLAY
+ case 2: if (*q == '$') /* RPlayHost */
+ { /* Check for $HOSTDISPLAY */
+ char *c1= (char *)getenv(q+1), *c2= host;
+ while (c1 && *c1 != ':')
+ *c2++ = *c1++;
+ *c2 = '\0';
+ }
+ else
+ strcpy(host, q);
+ break;
+ case 3: priority = atoi(q); break; /* RplayPriority */
+ case 4: volume = atoi(q); break; /* RplayVolume */
+#endif
+ }
+ }
+ else /* test for isspace(*p) ??? */
+ {
+ event = GetArgument(&p);
+ action = GetArgument(&p);
+INFO(event);
+INFO(" ");
+INFO(action);
+INFO("\n");
+ if (!event || !*event || !action || !*action)
+ {
+ fprintf(stderr,"%s: incomplete event definition %s\n",
+ MyName+1, buf);
+ continue;
+ }
+ for (found = 0,i = 0; !found && i < MAX_MESSAGES+MAX_BUILTIN;
+ i++)
+ {
+INFO(events[i]);
+INFO("\n");
+
+ if (MatchToken(event, events[i]))
+ {
+#ifdef HAVE_RPLAY
+ rplay_table[i] = rplay_create(RPLAY_PLAY);
+ rplay_set(rplay_table[i], RPLAY_APPEND,
+ RPLAY_SOUND, action,
+ RPLAY_PRIORITY, priority,
+ RPLAY_VOLUME, volume,
+ NULL);
+#endif
+ action_table[i]=action;
+ found=1;
+INFO("found\n");
+ }
+ }
+ if (!found) fprintf(stderr,"%s: unknown event type: %s\n",
+ MyName+1, event);
+ }
+ }
+/*else INFO("NO CONFIG\n");*/
+ }
+
+#ifdef HAVE_RPLAY
+ /*
+ * Builtin rplay support is enabled when FvwmAudioPlayCmd == builtin-rplay.
+ */
+ if (strcasecmp(cmd_line, "builtin-rplay") == 0)
+ if ((rplay_fd = rplay_open(host)) < 0)
+ {
+ rplay_perror("rplay_open");
+ exit(1);
+ }
+#endif
+}
+
+/***********************************************************************
+ *
+ * Procedure:
+ * SIGPIPE handler - SIGPIPE means fvwm is dying
+ *
+ ***********************************************************************/
+static RETSIGTYPE
+TerminateHandler(int nonsense)
+{
+ isTerminated = True;
+}
+
+/***********************************************************************
+ *
+ * Procedure:
+ * Externally callable procedure to quit
+ *
+ ***********************************************************************/
+void DeadPipe(int flag)
+{
+ execute_event(BUILTIN_SHUTDOWN);
+ exit(flag);
+}
diff --git a/app/fvwm/modules/FvwmEvent/Imakefile b/app/fvwm/modules/FvwmEvent/Imakefile
new file mode 100644
index 000000000..d26905edf
--- /dev/null
+++ b/app/fvwm/modules/FvwmEvent/Imakefile
@@ -0,0 +1,6 @@
+# $OpenBSD: Imakefile,v 1.1.1.1 2006/11/26 10:53:46 matthieu Exp $
+
+FVWMTOP=../..
+#include "../../Fvwm.tmpl"
+
+FvwmSimpleModuleTarget(FvwmEvent)