+
Skip to content

FvwmEvent - Remove FvwmAudio compatibility. #1111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 28 additions & 44 deletions doc/FvwmEvent.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
+
Expand Down Expand Up @@ -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

Expand Down
151 changes: 40 additions & 111 deletions modules/FvwmEvent/FvwmEvent.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down Expand Up @@ -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 '*' */
Expand All @@ -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))
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -357,15 +343,15 @@ 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]);
continue;
}
else
{
start_audio_delay = 0;
start_delay = 0;
}

/* event will equal the number of shifts in the base-2
Expand Down Expand Up @@ -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;
}
Expand All @@ -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 */
Expand Down Expand Up @@ -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
Expand Down
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载