Skip to main content
added 78 characters in body
Source Link

Building on Barry Wark's answer... NSBeep() from AppKit works fine, but also makes the terminal/app icon in the taskbar jump. A few extra lines with NSSound() avoids that and gives the opportunity to use another sound:

from AppKit import NSSound #prepare sound: sound = NSSound.alloc() sound.initWithContentsOfFile_byReference_('/System/Library/Sounds/Ping.aiff', True) #rewind and play whenever you need it: sound.stop() #rewind sound.play() 

Standard sound files can be found via commandline locate /System/Library/Sounds/*.aiff The file used by NSBeep() seems to be '/System/Library/Sounds/Funk.aiff'

Building on Barry Wark's answer... NSBeep() from AppKit works fine, but also makes the terminal/app icon in the taskbar jump. A few extra lines with NSSound() avoids that and gives the opportunity to use another sound:

from AppKit import NSSound #prepare sound: sound = NSSound.alloc() sound.initWithContentsOfFile_byReference_('/System/Library/Sounds/Ping.aiff', True) #rewind and play whenever you need it: sound.stop() #rewind sound.play() 

Standard sound files can be found via commandline locate /System/Library/Sounds/*.aiff

Building on Barry Wark's answer... NSBeep() from AppKit works fine, but also makes the terminal/app icon in the taskbar jump. A few extra lines with NSSound() avoids that and gives the opportunity to use another sound:

from AppKit import NSSound #prepare sound: sound = NSSound.alloc() sound.initWithContentsOfFile_byReference_('/System/Library/Sounds/Ping.aiff', True) #rewind and play whenever you need it: sound.stop() #rewind sound.play() 

Standard sound files can be found via commandline locate /System/Library/Sounds/*.aiff The file used by NSBeep() seems to be '/System/Library/Sounds/Funk.aiff'

Source Link

Building on Barry Wark's answer... NSBeep() from AppKit works fine, but also makes the terminal/app icon in the taskbar jump. A few extra lines with NSSound() avoids that and gives the opportunity to use another sound:

from AppKit import NSSound #prepare sound: sound = NSSound.alloc() sound.initWithContentsOfFile_byReference_('/System/Library/Sounds/Ping.aiff', True) #rewind and play whenever you need it: sound.stop() #rewind sound.play() 

Standard sound files can be found via commandline locate /System/Library/Sounds/*.aiff