Differences between version 3 and predecessor to the previous major change of UdevSounds.
Other diffs: Previous Revision, Previous Author
Newer page: | version 3 | Last edited on Saturday, 27 August 2011 9:08:56 | by CyberLeo | Revert |
Older page: | version 2 | Last edited on Tuesday, 21 August 2007 2:11:49 | by CyberLeo | Revert |
@@ -7,26 +7,23 @@
<verbatim>
#!/bin/bash
#logger -t "hw.sh" "$(whoami) Honoring ${ACTION} for ${SUBSYSTEM}..."
+add="/etc/udev/sounds/hw_insert.wav"
+rem="/etc/udev/sounds/hw_remove.wav"
-if
[ "${SUBSYSTEM}" !
= "usb" ]
-then
-
exit 0
-fi
+[ "${SUBSYSTEM}" =
= "usb" ] ||
exit 0
-if [
"${ACTION}" = "add" ]
-then
- /usr/bin/aplay /etc/udev/sounds/hw_insert.wav &
- exit 0
-elif
[ "${ACTION
}" = "remove
" ]
-then
-
/usr/bin/aplay /etc/udev/sounds/hw_remove.wav
&
- exit 0
-fi
+case
"${ACTION}" in
+add) snd
="${
add}
" ;;
+remove) snd="${rem}" ;;
+*) ;;
+esac
+
+[ "${snd
}" ] &&
/usr/bin/aplay -q "${snd}"
&
</verbatim>
Note that aplay likely won't work if you have a sound manager like esd squatting on the sound devices, so set it to give them up after a while.
Also, sound managers like esd won't work because they disallow connections from sources that don't match credentials
Salt and pepper to taste...
version 3
/etc/udev.rules/00-bling.rules:
RUN+="/etc/udev/sounds/hw.sh"
/etc/udev/sounds/hw.sh:
#!/bin/bash #logger -t "hw.sh" "$(whoami) Honoring ${ACTION} for ${SUBSYSTEM}..." add="/etc/udev/sounds/hw_insert.wav" rem="/etc/udev/sounds/hw_remove.wav" [ "${SUBSYSTEM}" == "usb" ] || exit 0 case "${ACTION}" in add) snd="${add}" ;; remove) snd="${rem}" ;; *) ;; esac [ "${snd}" ] && /usr/bin/aplay -q "${snd}" &
Note that aplay likely won't work if you have a sound manager like esd squatting on the sound devices, so set it to give them up after a while.
Also, sound managers like esd won't work because they disallow connections from sources that don't match credentials
Salt and pepper to taste...