# 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](https://www.hexnode.com/mobile-device-management/help/how-to-run-scripts-on-mac-using-hexnode-mdm/) 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

 Disclaimer: 
The sample scripts provided below are adapted from third-party open-source sites.

 

 
 Note: 
The below scripts will only affect the currently logged in user.

 

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.

Script to change alert sound

\#!/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

   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.

[![Set alert sound to Submerge](https://cdn.hexnode.com/mobile-device-management/help/wp-content/uploads/2023/06/Change-alert-sound.png "Change alert sound")](https://cdn.hexnode.com/mobile-device-management/help/wp-content/uploads/2023/06/Change-alert-sound.png) Note: 
You can deploy the following script to list the available alert sounds on the device.

Script to list alert sounds

\#!/bin/bash ls /System/Library/Sounds/

   1

2

  \#!/bin/bash 

ls /System/Library/Sounds/

   

 

  

[![List available alert sounds](https:2023/06/List-system-alert-sounds.png "List system alert sounds")](https:2023/06/List-system-alert-sounds.png)
 

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.

Script to change alert volume

\#!/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"

   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.

[![Set alert volume to 75](https:2023/06/Change-alert-volume.png "Change alert volume")](https:2023/06/Change-alert-volume.png) Notes:- It is recommended to manually validate the script execution on a system before executing the action in bulk.
- Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.