Differences between current version and predecessor to the previous major change of UdevSounds.

Other diffs: Previous Revision, Previous Author

Newer page: version 4 Last edited on Saturday, 27 August 2011 9:24:21 by CyberLeo
Older page: version 2 Last edited on Tuesday, 21 August 2007 2:11:49 by CyberLeo Revert
@@ -6,27 +6,24 @@
 /etc/udev/sounds/hw.sh: 
 <verbatim> 
 #!/bin/bash 
  
-#logger -t "hw.sh" "$(whoami) Honoring ${ACTION} for ${SUBSYSTEM}...
+#logger -t "hw.sh" "$(whoami) Sounding ' ${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... 

current version

/etc/udev.rules/00-bling.rules:

RUN+="/etc/udev/sounds/hw.sh"

/etc/udev/sounds/hw.sh:

#!/bin/bash

#logger -t "hw.sh" "$(whoami) Sounding '${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...