[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[patch] execute command instead of beep (xchat2 gtk-fe)
Hi,
attached a small patch that lets the user specify a command to run whenever a
beep is called for (instead of using the stock gdk_beep() call, which sounds
horrible, does not work for me with kernel 2.6, and doesn't deliver the sound
where I want it to go (ie. NAS in my case)).
Patch is against current cvs.
Hope someone finds it useful.
Cheers
-Tim
Index: common/cfgfiles.c
===================================================================
RCS file: /cvsroot/xchat/xchat2/src/common/cfgfiles.c,v
retrieving revision 1.41
diff -u -b -r1.41 cfgfiles.c
--- common/cfgfiles.c 21 Sep 2003 12:17:30 -0000 1.41
+++ common/cfgfiles.c 10 Oct 2003 18:57:58 -0000
@@ -379,6 +379,7 @@
{"gui_auto_open_dialog", P_OFFINT (autodialog), TYPE_BOOL},
{"gui_auto_open_recv", P_OFFINT (autoopendccrecvwindow), TYPE_BOOL},
{"gui_auto_open_send", P_OFFINT (autoopendccsendwindow), TYPE_BOOL},
+ {"gui_beep_exec_cmd", P_OFFSET(beepexeccmd), TYPE_STR},
{"gui_dialog_height", P_OFFINT (dialog_height), TYPE_INT},
{"gui_dialog_left", P_OFFINT (dialog_left), TYPE_INT},
{"gui_dialog_top", P_OFFINT (dialog_top), TYPE_INT},
Index: common/xchat.h
===================================================================
RCS file: /cvsroot/xchat/xchat2/src/common/xchat.h,v
retrieving revision 1.24
diff -u -b -r1.24 xchat.h
--- common/xchat.h 23 Jul 2003 09:16:41 -0000 1.24
+++ common/xchat.h 10 Oct 2003 18:57:58 -0000
@@ -112,6 +112,7 @@
#ifdef USE_ZVT
char font_shell[FONTNAMELEN + 1];
#endif
+ char beepexeccmd[511]; /* eek, fixed-length string buffers */
char doubleclickuser[256];
char sounddir[PATHLEN + 1];
char soundcmd[PATHLEN + 1];
Index: fe-gtk/fe-gtk.c
===================================================================
RCS file: /cvsroot/xchat/xchat2/src/fe-gtk/fe-gtk.c,v
retrieving revision 1.25
diff -u -b -r1.25 fe-gtk.c
--- fe-gtk/fe-gtk.c 10 Sep 2003 10:56:55 -0000 1.25
+++ fe-gtk/fe-gtk.c 10 Oct 2003 18:57:59 -0000
@@ -589,6 +589,30 @@
void
fe_beep (void)
{
+ if (prefs.beepexeccmd[0] != 0x00)
+ {
+ static guint lastcmdhash = 0; /* avoid error message dialog flooding */
+ GError *error = NULL;
+ gchar *errmsg;
+
+ if (g_spawn_command_line_async(prefs.beepexeccmd, &error))
+ {
+ lastcmdhash = 0;
+ return;
+ }
+
+ if (lastcmdhash == 0 || lastcmdhash != g_str_hash(prefs.beepexeccmd))
+ {
+ errmsg = g_strdup_printf(_("Beep command '%s' failed: %s\n"), prefs.beepexeccmd, error->message);
+ gtkutil_simpledialog (errmsg);
+ g_free(errmsg);
+ }
+
+ lastcmdhash = g_str_hash(prefs.beepexeccmd);
+
+ g_error_free(error);
+ }
+
gdk_beep ();
}
Index: fe-gtk/setup.c
===================================================================
RCS file: /cvsroot/xchat/xchat2/src/fe-gtk/setup.c,v
retrieving revision 1.27
diff -u -b -r1.27 setup.c
--- fe-gtk/setup.c 3 Aug 2003 08:20:50 -0000 1.27
+++ fe-gtk/setup.c 10 Oct 2003 18:58:00 -0000
@@ -218,6 +218,7 @@
{ST_TOGGLE, N_("Whois on notify"), P_OFFINT(whois_on_notifyonline), N_("Sends a /WHOIS when a user comes online in your notify list"), 0, 0},
{ST_TOGGLE, N_("Hide join/part messages"), P_OFFINT(confmode), N_("Hide channel join/part messages by default"), 0, 0},
{ST_NUMBER, N_("Auto reconnect delay:"), P_OFFINT(recon_delay), 0, 0, 9999},
+ {ST_ENTRY, N_("Command to execute on beep (optional):"), P_OFFSET(beepexeccmd), 0, 0, sizeof prefs.beepexeccmd},
{ST_END, 0, 0, 0, 0, 0}
};