SlapMacBlogDownload
All posts

Guides

How to make your Mac play a sound when you plug in USB

By Tonnoz3 min read

You can't, out of the box. Windows plays its little two-note chime when you plug something in, but a Mac stays silent, and there's no setting for it anywhere in System Settings. You need an app.

There are two good ways to do it. If you want a normal, quiet sound, a free tool called Hammerspoon does it in a few lines. If you want your MacBook to groan every time you plug in a mouse, SlapMac has a mode for that.

The free way: Hammerspoon

Hammerspoon is a free, open-source automation app for the Mac. You control it with short scripts written in Lua, and it has a USB watcher built in. You don't need to know Lua for this, just copy and paste.

  1. Download Hammerspoon from hammerspoon.org, or run brew install --cask hammerspoon if you use Homebrew. Move it to Applications and open it.
  2. Click the hammer icon in the menu bar and choose Open Config. A file called init.lua opens in your text editor.
  3. Paste this in and save:
usbSound = hs.usb.watcher.new(function(device)
  if device.eventType == "added" then
    hs.sound.getByName("Glass"):play()
  elseif device.eventType == "removed" then
    hs.sound.getByName("Bottle"):play()
  end
end)
usbSound:start()
  1. Click the hammer icon again and choose Reload Config.

Plug something in and you'll hear the Glass sound. Unplug it and you'll hear Bottle.

A few tips:

  • Leave out the word local. The watcher has to stay in a global variable. If it's local, Lua's garbage collector quietly throws it away after a while and the sounds just stop.
  • Pick other sounds. The classic macOS sounds work by name: Basso, Blow, Bottle, Frog, Funk, Glass, Hero, Morse, Ping, Pop, Purr, Sosumi, Submarine and Tink. For your own file, use hs.sound.getByFile("/path/to/sound.mp3") instead.
  • Only one device. Every event comes with the device's name. Add print(device.productName) inside the function, plug the device in, and open the Hammerspoon Console to see what it's called. Then wrap the sound in if device.productName == "That Name" then ... end.
  • Docks can get noisy. A USB-C dock or hub contains several devices, so plugging one in can fire a small burst of sounds.

The silly way: SlapMac's USB Moaner

SlapMac is mostly known for making your MacBook scream when you slap it. It also has a mode called USB Moaner: plug in or unplug any USB device and your Mac reacts out loud, no slapping required.

It uses the same voice packs as slap mode, so you can choose the sound to match your mood. Goat bleats. Gentleman voices polite disapproval. Fart is exactly what you'd expect. There are nine packs and more than 150 clips. Maybe switch it off before plugging in a webcam for a client call.

SlapMac runs in the menu bar on MacBooks with M1 Pro or newer and macOS 14.6 or later.

Which one should you use?

Use Hammerspoon if you want a simple, normal chime and you're fine with a few lines of config. It's free, it's tiny, and you can grow it into a lot more automation later.

Use SlapMac if you'd like your Mac to have opinions about USB, and about being slapped, and maybe about being stolen too.

If you just want to know whether a drive connected

If the real problem is not being sure your external drive mounted, there's an easier fix than sound. Open Finder, choose Settings from the Finder menu, and under General tick "External disks". Every drive you connect will now show up as an icon on your desktop.