From 0343e6910281d6741c40e5a57f9ff53bebd0681c Mon Sep 17 00:00:00 2001 From: Jaimos Skriletz Date: Thu, 14 Nov 2024 23:53:17 -0700 Subject: [PATCH] FvwmEvent - Remove FvwmAudio compatibility. FvwmEvent -audio and FvwmAudio have been broken for years and librplay support has been removed. There is no longer a need for the code that isn't doing anything. This removes any code associated with FvwmAudio compatibility in FvwmEvent and updates the manual page to remove mention of any backwards compatibility with the older module. --- doc/FvwmEvent.adoc | 72 +++++++--------- modules/FvwmEvent/FvwmEvent.c | 151 +++++++++------------------------- 2 files changed, 68 insertions(+), 155 deletions(-) diff --git a/doc/FvwmEvent.adoc b/doc/FvwmEvent.adoc index d5d4c6d08..9939a8cd3 100644 --- a/doc/FvwmEvent.adoc +++ b/doc/FvwmEvent.adoc @@ -11,52 +11,35 @@ FvwmEvent - the fvwm event module -== SYNOPSIS +== DESCRIPTION + +_FvwmEvent_ is a module that triggers actions on _fvwm_ events. +It can be used to hook any _fvwm_ function or program to any window +manager event. _FvwmEvent_ can trigger actions when windows are +added, deleted, iconified, shaded, or when _fvwm_ changes which +virtual page or desk is being shown, or when RandR monitors are +changed, enabled, disabled, or gain focus. Be creative, you'll +find a use for it. -_FvwmEvent_ is a more versatile replacement for _FvwmAudio_. It can in -general be used to hook any _fvwm_ function or program to any window -manager event. E.g: Delete unwanted Netscape Pop ups or application -error pop ups as they appear, play sounds, log events to a file and the -like. Be creative, you'll find a use for it. +== INVOCATION _FvwmEvent_ is spawned by _fvwm_, so no command line invocation will -work. From within the _.fvwm2rc_ file, _FvwmEvent_ is spawned as -follows: +work. _FvwmEvent_ can be spawned from within the _config_ file +with or without an _Alias_ as follows: .... -Module FvwmEvent +Module FvwmEvent Alias .... -or from within an _fvwm_ pop-up menu: +You can add this to the _StartFunction_ to ensure _FvwmEvent_ +is running and listening for events when _fvwm_ starts. Alternatively +you can add this to a menu, key binding, etc. You can kill stop +a running instance of _FvwmEvent_ with: .... -DestroyMenu Module-Popup -AddToMenu Module-Popup "Modules" Title -+ "Event" Module FvwmEvent -+ "Auto" Module FvwmAuto 200 -+ "Buttons" Module FvwmButtons -+ "Console" Module FvwmConsole -+ "Ident" Module FvwmIdent -+ "Banner" Module FvwmBanner -+ "Pager" Module FvwmPager 0 3 +KillModule FvwmEvent Alias .... -== DESCRIPTION - -The _FvwmEvent_ module communicates with the _fvwm_ window manager to -bind _actions_ to window manager _events_. Different actions may be -assigned to distinct window manager events. - -_FvwmEvent_ can be used to bind sound files to events like _FvwmAudio_ -(RiP) did. It can be used for logging event traces to a log file, while -debugging _fvwm_. - -== INVOCATION - -The invocation method was shown in the synopsis section. No command line -invocation is possible. _FvwmEvent_ must be invoked by the _fvwm_ window -manager. - == CONFIGURATION OPTIONS _FvwmEvent_ gets config info from *fvwm*'s module configuration database @@ -105,12 +88,14 @@ setting *FvwmEvent: PassId:: Specifies that the event action will have an ID parameter added to the end of the command line. Most events will have the windowID of the - window that the event refers to, new_desk will have the new desk - number. The windowID is a hexadecimal string preceded by 0x, desk - numbers are decimal. - -*FvwmEvent: window-manager-event action-or-filename:: - Binds particular actions to window manager events. + window that the event refers to. The new_desk event will have the new + desk number. Monitor events will have the RandR monitor name. The + windowID is a hexadecimal string preceded by 0x, desk numbers are + decimal, and monitor name's are strings. + +*FvwmEvent: window-manager-event action:: + Binds particular actions to window manager events. The action is + appended to the _Cmd_ which is then sent to _fvwm_ for execution. + The following events are valid: + @@ -200,9 +185,8 @@ on a similar Fvwm module called _FvwmSound_ by Mark Boyns. _FvwmAudio_ 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, _FvwmEvent_ took this one step -further and now calls any _fvwm_ function, or builtin-rplay. If _fvwm_'s -Exec function is used, any external program can be called with any -parameter. +further and now calls any _fvwm_ function. If _fvwm_'s Exec function +is used, any external program can be called with any parameter. == AUTHORS diff --git a/modules/FvwmEvent/FvwmEvent.c b/modules/FvwmEvent/FvwmEvent.c index 2240aa039..397c30c3e 100644 --- a/modules/FvwmEvent/FvwmEvent.c +++ b/modules/FvwmEvent/FvwmEvent.c @@ -87,14 +87,12 @@ static char *MyName; static int MyNameLen; static int fd[2]; static char *cmd_line = NULL; -static time_t audio_delay = 0; /* seconds */ +static time_t delay = 0; /* seconds */ static time_t last_time = 0; static time_t now; -static time_t start_audio_delay = 0; +static time_t start_delay = 0; /* don't tag on the windowID by default */ static Bool PassID = False; -static Bool audio_compat = False; -static char *audio_play_dir = NULL; #define ARG_NO_WINID 1024 /* just a large number */ @@ -231,15 +229,8 @@ int main(int argc, char **argv) } if (argc == 7) { - if (strcmp(argv[6], "-audio") == 0) - { - audio_compat = True; - } - else - { - /* use an alias */ - s = argv[6]; - } + /* use an alias */ + s = argv[6]; } /* account for '*' */ @@ -249,11 +240,6 @@ int main(int argc, char **argv) *MyName='*'; /* append name */ strcpy(MyName+1, s); - if (StrEquals("FvwmAudio", s)) - { - /* catch the FvwmAudio alias */ - audio_compat = True; - } /* Now MyName is defined */ if ((argc != 6)&&(argc != 7)) @@ -293,7 +279,7 @@ int main(int argc, char **argv) config(); /* Startup event */ execute_event(builtin_event_table, BUILTIN_STARTUP, NULL); - if (start_audio_delay) + if (start_delay) { last_time = time(0); } @@ -357,7 +343,7 @@ int main(int argc, char **argv) total +=count; } - if (now < last_time + audio_delay + start_audio_delay) + if (now < last_time + delay + start_delay) { /* quash event */ unlock_event(header[1]); @@ -365,7 +351,7 @@ int main(int argc, char **argv) } else { - start_audio_delay = 0; + start_delay = 0; } /* event will equal the number of shifts in the base-2 @@ -414,74 +400,40 @@ int main(int argc, char **argv) */ void execute_event(event_entry *event_table, short event, unsigned long *body) { - if (event_table[event].action.action != NULL) - { - char *buf = NULL; - int len = 0; - char *action; + if (event_table[event].action.action == NULL) + return; - action = event_table[event].action.action; - len = strlen(cmd_line) + strlen(action) + 32; - if (audio_play_dir) - { - len += strlen(audio_play_dir); - } - buf = fxmalloc(len); - if (audio_compat) - { - /* Don't use audio_play_dir if it's NULL or if - * the sound file is an absolute pathname. */ - if (!audio_play_dir || audio_play_dir[0] == '\0' || - action[0] == '/') - { - snprintf(buf,len,"%s %s", cmd_line, action); - } - else - { - snprintf(buf,len,"%s %s/%s &", cmd_line, - audio_play_dir, action); - } - if (!system(buf)) - { - last_time = now; - } + char *buf = NULL; + int len = 0; + char *action; + int action_arg = event_table[event].action_arg; + int fw = 0; + + action = event_table[event].action.action; + len = strlen(cmd_line) + strlen(action) + 32; + buf = fxmalloc(len); + + if (action_arg != -1 && !(action_arg & ARG_NO_WINID)) + fw = body[action_arg]; + + if (PassID && action_arg != -1) { + if (action_arg & ARG_NO_WINID) { + action_arg &= ~ARG_NO_WINID; + snprintf(buf, len, "%s %s %ld", cmd_line, + action, body[action_arg]); + } else { + snprintf(buf, len, "%s %s 0x%lx", cmd_line, + action, body[action_arg]); } - else - { - int action_arg = event_table[event].action_arg; - int fw = 0; + } else { + snprintf(buf, len,"%s %s", cmd_line, action); + } - if (action_arg != -1 && !(action_arg & ARG_NO_WINID)) - { - fw = body[action_arg]; - } + /* let fvwm execute the function */ + SendText(fd, buf, fw); + last_time = now; - if (PassID && action_arg != -1) - { - if (action_arg & ARG_NO_WINID) - { - action_arg &= ~ARG_NO_WINID; - snprintf(buf, len, "%s %s %ld", cmd_line, - action, body[action_arg]); - } - else - { - snprintf(buf, len, "%s %s 0x%lx", cmd_line, - action, body[action_arg]); - } - } - else - { - snprintf(buf, len,"%s %s", cmd_line, action); - } - /* let fvwm execute the function */ - SendText(fd, buf, fw); - last_time = now; - } - free(buf); - - return; - } + free(buf); return; } @@ -508,7 +460,6 @@ void handle_config_line(char *buf) { "Cmd", "Delay", - "Dir", "PassID", "StartDelay" }; /* define entries here, if this list becomes unsorted, use FindToken */ @@ -538,46 +489,24 @@ void handle_config_line(char *buf) cmd_line = fxstrdup(""); } break; - case 1: /* Delay */ if (token) { - audio_delay = atoi(token); + delay = atoi(token); } break; - case 2: - /* Dir */ - if (!audio_compat) - { - fvwm_debug(__func__, - "%s: Dir supported only when invoked as" - " FvwmAudio\n", MyName+1); - break; - } - if (token) - { - if (audio_play_dir) - { - free(audio_play_dir); - } - audio_play_dir = fxstrdup(token); - } - break; - - case 3: /* PassID */ PassID = True; break; - case 4: + case 3: /* StartDelay */ if (token) { - start_audio_delay = atoi(token); + start_delay = atoi(token); } break; - } } else