Category filter
Script to change alert sound and volume settings on macOS devices
Alert sounds on Mac are generally generated alongside alert messages when the device needs to prompt the user for input or relay some information. With Hexnode’s Execute Custom Script action, you can deploy these scripts to set the preferred alert sound or adjust the alert volume on your macOS devices.
Scripting language – Bash
File extension – .sh
Change alert sound
By default, the alert sound is set on Tink. You can set any of the alert sounds installed on the device by default such as Basso, Funk, Glass, Ping, Pop, Submarine, etc.
To modify the alert sound, deploy the following script.
1 2 3 4 |
#!/bin/bash CurrentUser=$(ls -l /dev/console | awk '/ / { print $3 }') CurrentUserUID=$(id -u "$CurrentUser") launchctl asuser $CurrentUserUID sudo -iu "$CurrentUser" defaults write .GlobalPreferences com.apple.sound.beep.sound /System/Library/Sounds/$1.aiff |
Mention the name of your preferred alert sound as an argument in the Arguments field while deploying the script. For example, to set alert sound as Submarine, add Submarine to the Arguments field.
Change alert volume
Deploy the following script to set the alert volume as per your preference. Enter the desired alert volume ranging from 0-100 (in terms of percentage) as an argument in the Arguments field while deploying the script.
1 2 3 4 |
#!/bin/bash CurrentUser=$(ls -l /dev/console | awk '/ / { print $3 }') CurrentUserUID=$(id -u "$CurrentUser") launchctl asuser $CurrentUserUID sudo -iu "$CurrentUser" osascript -e "set volume alert volume $1" |
For example, to set alert volume to 75%, add 75 to the Arguments field.