Note: You are viewing an old version of this page. View the current version.

This is not USB-only, and causes an annoying ruckus on initial startup, but it works.

This will play attach and detach sounds whenever any device is attached or detached, including USB devices, network interfaces (tun) PCMCIA devices, etc.. Basically anything that generates an 'attach' or 'detach' event will play the appropriate sound.

Also note that you will have to patch all other attach and notify sections of the file to include calls to the appropriate script, because only one section will be called for any given event, based on its position in the file and priority number. Annoying.

/etc/devd.conf:

notify 0 {
        match "system" "ACPI";
        match "subsystem" "Lid";
        match "notify" "0x00";
        action "/usr/local/etc/sounds/hw.sh remove";
};
notify 0 {
        match "system" "ACPI";
        match "subsystem" "Lid";
        match "notify" "0x01";
        action "/usr/local/etc/sounds/hw.sh add";
};
attach 0 {
        action "/usr/local/etc/sounds/hw.sh add";
};

detach 0 {
        action "/usr/local/etc/sounds/hw.sh remove";
};

/usr/local/etc/sounds/hw.sh:

#!/bin/sh

play="/usr/local/bin/waveplay";

add="/usr/local/etc/sounds/hw_insert.wav";
rem="/usr/local/etc/sounds/hw_remove.wav";

logger -t "hw.sh" "$(whoami) Honoring ${1}"

case "${1}" in
add)
        ${play} ${add} > /dev/null 2>&1 &
        ;;
remove)
        ${play} ${rem} > /dev/null 2>&1 &
        ;;
esac