Created
June 20, 2024 17:07
-
-
Save MateusBMP/e41362c38a500067dfea935d3e3234b3 to your computer and use it in GitHub Desktop.
Play a sound using the speaker
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
| #!/bin/bash | |
| # | |
| # Play a sound using the speaker | |
| # | |
| # Usage: ./play_sound.sh [time] | |
| # time: time in seconds to play the sound (default: 0.1) | |
| if ! command -v speaker-test &> /dev/null | |
| then | |
| echo "speaker-test could not be found" | |
| exit 1 | |
| fi | |
| if [ $# -gt 1 ] | |
| then | |
| echo "Usage: $0 [time]" | |
| echo " time: time in seconds to play the sound (default: 0.1)" | |
| exit 1 | |
| fi | |
| TIME=.1 | |
| if [ $# -eq 1 ] | |
| then | |
| TIME=$1 | |
| fi | |
| speaker-test -t sine -f 1000 -l 1 > /dev/null 2>&1 & sleep "$TIME" && kill -9 $! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment