gianmarco
/
dotfiles
Archived
1
0
Fork 0
This repository has been archived on 2024-02-08. You can view files and clone it, but cannot push or open issues/pull-requests.
dotfiles/Scripts/usbsounds.sh

29 lines
801 B
Bash
Executable File

#!/bin/sh
# USB Insert / Remove sound script
# Created by om3ganet (msn@om3ga.net)
# --------------------------------------------------
# This script could probably be cleaned up, and add checking
# of unrecognised usb sounds (and play fail noise)
# change this if you want sounds elsewhere
SNDDIR=~/Sounds/;
# check frequency (default 0.25 seconds)
CHECKFREQ=0.25
# Do not edit below this line
# --------------------------------------------------
DEVCOUNT=`lsusb | wc -l | awk '{ print $1 }'`
OLDDEVCOUNT=$DEVCOUNT;
while(true) do
sleep $CHECKFREQ;
DEVCOUNT=`lsusb | wc -l | awk '{ print $1 }'`
if [ $DEVCOUNT -gt $OLDDEVCOUNT ]; then
play `echo $SNDDIR`devinsert.wav;
elif [ $DEVCOUNT -lt $OLDDEVCOUNT ]; then
play `echo $SNDDIR`devremove.wav;
fi
OLDDEVCOUNT=$DEVCOUNT;
done