scriptkitties.com

Random Programming Projects in C, Delphi, Lazarus and TCL

Temporarily Disable Sounds in HexChat

I recently switched from XChat to HexChat and found that my TclPlugin script to temporarily turn sounds off stopped working.  Within HexChat, I didn't see a way to implement this with a plugin so I ended up patching the source directly.  Here are the 3 unified diff files to apply via the patch utility.

After patching, use:

/set sound on
/set sound off

to disable and re-enable sounds.

I did submit this as a patch to the HexChat team but they rejected it with the reason "Checking the 'Omit alert when marked as being away' box disables sounds when marked as being away.  #2012" which is not the purpose of this patch.

Index: src/common/cfgfiles.c
===================================================================
--- src/common/cfgfiles.c   (original)
+++ src/common/cfgfiles.c   (working copy)
@@ -553,6 +553,8 @@
 
        {"perl_warnings", P_OFFINT (hex_perl_warnings), TYPE_BOOL},
 
+        {"sound", P_OFFINT (hex_sound), TYPE_BOOL},
+
        {"stamp_log", P_OFFINT (hex_stamp_log), TYPE_BOOL},
        {"stamp_log_format", P_OFFSET (hex_stamp_log_format), TYPE_STR},
        {"stamp_text", P_OFFINT (hex_stamp_text), TYPE_BOOL},
@@ -836,6 +838,7 @@
        prefs.hex_irc_join_delay = 5;
        prefs.hex_net_reconnect_delay = 10;
        prefs.hex_notify_timeout = 15;
+       prefs.hex_sound = 1;
        prefs.hex_text_max_indent = 256;
        prefs.hex_text_max_lines = 500;
        prefs.hex_url_grabber_limit = 100;              /* 0 means unlimited */
Index: src/common/hexchat.h
===================================================================
--- src/common/hexchat.h    (original)
+++ src/common/hexchat.h    (working copy)
@@ -234,6 +234,7 @@
        unsigned int hex_net_throttle;
        unsigned int hex_notify_whois_online;
        unsigned int hex_perl_warnings;
+       unsigned int hex_sound;
        unsigned int hex_stamp_log;
        unsigned int hex_stamp_text;
        unsigned int hex_text_autocopy_color;
Index: src/common/text.c
===================================================================
--- src/common/text.c       (original)
+++ src/common/text.c       (working copy)
@@ -2277,6 +2277,11 @@
        char *cmd;
 #endif
 
+       if (!prefs.hex_sound)
+       {
+               return;
+       }
+
        /* the pevents GUI editor triggers this after removing a soundfile */
        if (!file[0])
        {