Skip to content

Commit

Permalink
Update driver loading script. It now uses better file locking.
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardoEPRodrigues committed Feb 14, 2021
1 parent a81d708 commit b6d4df0
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions scripts/magic-mouse-2-add.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
#!/bin/sh

FILE=/tmp/magicmouse-driveload
FILE=/tmp/magicmouse.lock

reload() {
if [ ! -f "$FILE" ]; then
touch $FILE

modprobe -r hid_magicmouse
sleep 2
modprobe -a hid-generic hid_magicmouse

sleep 2
rm -f "$FILE"

# Check is Lock File exists, if not create it and set trap on exit
if { set -C; 2>/dev/null >$FILE; }; then
trap "rm -f $FILE" EXIT
else
# Lock file exists. exiting.
exit
fi

modprobe -r hid_magicmouse
sleep 2
modprobe -a hid-generic hid_magicmouse
sleep 2
}

reload &

0 comments on commit b6d4df0

Please sign in to comment.