Make a beep sound

Hi im running osmc and i wanna implement a beep sound in my bash script to let me know when its done . i tried using beep software or echoin -n “\a” with no luck

I assume you are using a Raspberry Pi. This doesn’t have a speaker built-in

Sam

yes im suing osmc on rpi2 my rpi is connected to tv via hdmi which does carry sound . it doesnt matter if rpi doesnt have a speaker i wanna play that beep via this tv so i would know the result of of bash script w/o h having to check with ssh

Enable snd_bcm2835
use aplay to play a beep

1 Like

Another approach is there may be a Kodi built in command that you can use to play a sound using xbmc-send. Or, some skins play an alert sound for pop up notifications - so you could send a popup notification using xbmc-send that will both display a brief popup message on the screen and play the alert sound.

can u name a function that does that whci hi can use in bash ?

i did enable this kernel module with
sudo modprobe snd_bcm2835

now for the second line i need to install aplay via apt-get right? is it ok ? does it affect my performance on rpi2?

Have a look at the list of Kodi built in functions.

To send one, use xbmc-send from a bash script. For example:

xbmc-send -a 'Notification("Message header","Message Body")'
1 Like

thanks @DBMandrake thats what i wanted but i didn’t know that :slight_smile:
one more thing is there a way that i can pipe a cat result into “Message Body” ?
i want the message body to be contents of a small log file i have . (cant use back ticks cat sth.txt)

Quoting is quite complicated with xbmc-send because you need quotes (single ticks in my example) around the whole command, but if your message has spaces you need quotes within the Notification command itself, this quickly gets confusing… :smile:

I use something similar to this:

xbmc-send -a 'Notification("Alert","'"${1}"'")'

Where the message body is in $1 (first command line argument of the script) so you could try something like:

message=$(cat myfile)
xbmc-send -a 'Notification("Alert","'"$message"'")'

Or this may work (haven’t tested it)

xbmc-send -a 'Notification("Alert","'"$(cat myfile)"'")'
1 Like

using ur help i made this script which then i run by using a python script which then i run that python script via a button and Built in RunScript() command which i have assigned a button on Yatse for. ( unfortunately i couldn’t run the bash script directly with any build in commands )

i went through all of the above to compensate for the fact that i couldn’t make this openconnet vpn client to run automatically at startup ( i made a support request about that which didnt help much > link )

hope my script helps some one trying to achive the same thing