Skip to content

Instantly share code, notes, and snippets.

@benatkin
Created January 5, 2009 23:31
Show Gist options
  • Save benatkin/43577 to your computer and use it in GitHub Desktop.
Save benatkin/43577 to your computer and use it in GitHub Desktop.
#!/bin/bash
# odde (Optical Drive Disabler and Enabler)
# Ben Atkin ([email protected])
# 2009-01-05
#
# NO WARRANTY!
#
# Please only run this if you can grok the code.
#
# This will disable and enable your optical drive. It requires a restart.
# It is not known what effect other software (including software updates)
# will have on this if they do anything with this kernel extension.
#
# I created this because I've found the optical drive noise my MacBook
# makes when it comes out of sleep to be annoying at times. Unfortunately
# it still makes that noise.
ddir='/System/Library/Disabled Extensions'
dkext='/System/Library/Disabled Extensions/IODVDStorageFamily.kext'
ekext='/System/Library/Extensions/IODVDStorageFamily.kext'
check_for_root ()
{
if [ $(id -u) != 0 ]; then
echo "You must be root to execute this script."
exit 67
fi
}
case $1 in
'disable')
check_for_root
if [ -a "$dkext" ]; then
echo "The optical drive has already been disabled. Try restarting."
exit 1
fi
echo 'Please remove any disc(s) from your optical drive(s) and press return.'
read
mkdir -p "$ddir" && mv "$ekext" "$dkext"
echo 'Your optical drive will be disabled after you restart.'
;;
'enable')
check_for_root
if [ -a "$ekext" ]; then
echo "The optical drive is already enabled. Try restarting."
exit 1
fi
mv "$dkext" "$ekext"
echo 'Your optical drive will be enabled after you restart.'
;;
*)
echo "usage: $0 disable or $0 enable"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment