# disclaimer: this cask formula was written by karen for internal use by herself and her friends
# feel free to use it if you stumble across this
# i also recommend that you use Soundflowerbed_volumecontrol.zip found in the same dir as this formula

cask 'soundflower-1.6.6b-karen_internal' do
  version '1.6.6b'
  sha256 '61ca31d7478d057e32caaeac3c739f965ba9eb2a27570b3cc715e706d4740dfb'

  # original soundflower 1.6.6b URL at google code is now a 404
  url "https://developer.angelxwind.net/macOS/Soundflower-#{version}.dmg"
  name 'Soundflower'
  homepage 'https://code.google.com/p/soundflower/'
  license :oss

  pkg 'Soundflower.pkg', allow_untrusted: true

  postflight do
    system '/usr/bin/sudo', '-E', '--',
           '/sbin/kextload', '-b', 'com.Cycling74.driver.Soundflower'
  end

  # early_script is a workaround for a slowly unloading kext, see private-eye Cask
  uninstall early_script: {
                            executable:   '/sbin/kextunload',
                            args:         ['-b', 'com.Cycling74.driver.Soundflower'],
                            must_succeed: false,
                          },
            pkgutil:      'com.cycling74.soundflower.*',
            delete:       '/Applications/Soundflower',
            kext:         'com.Cycling74.driver.Soundflower'
end
