Last active
August 7, 2021 12:21
-
-
Save FelDev/963910b1f2db11b46ef088e4c8da3d00 to your computer and use it in GitHub Desktop.
Random mac alert sound from Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import subprocess, random, glob | |
| print('HERE WE GO') | |
| sounds = glob.glob('/Users/{yourName}/Library/Sounds/*.aiff') | |
| sound = random.choice(sounds) | |
| print('randomly selected sound: ', sound) | |
| command = 'defaults write .GlobalPreferences com.apple.sound.beep.sound /Users/{yourName}/Library/Sounds/{}.aiff'.format(sound) | |
| # You could also define an array of sounds yourself, if you don't want every | |
| # .aiff file to be a possibility | |
| # sounds=['tabarnak1', 'tabarnak2', 'tabarnak3'] | |
| # sound=random.choice(sounds) | |
| # command = 'defaults write .GlobalPreferences com.apple.sound.beep.sound /Users/{yourName}/Library/Sounds/{}.aiff'.format(sound) | |
| subprocess.call(command, shell=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment