Skip to content

Instantly share code, notes, and snippets.

@honzajavorek
Created November 4, 2013 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save honzajavorek/7299300 to your computer and use it in GitHub Desktop.
Save honzajavorek/7299300 to your computer and use it in GitHub Desktop.
Script to connect SAMSUNG SBH-650 BLUETOOTH HEADSET and use it as default speakers
#!/bin/bash
# A script to connect my SAMSUNG SBH-650 BLUETOOTH HEADSET (I use it for remote speakers)
# address of the device (hcitool scan ... Samsung SBH650)
address="00:21:D2:A4:7B:E7"
# stop && shutdown moc
mocp -s
mocp -x
# restart service
sudo /etc/init.d/bluetooth restart
# start bluetooth
status=`/etc/init.d/bluetooth status | grep "is not running"`
if [ -n "$status" ]; then
echo "Bluetooth is stopped."
sudo /etc/init.d/bluetooth start
echo "Now bluetooth is running."
else
echo "Bluetooth is running."
fi
# find the device
found=`hcitool scan | grep "$address"`
if [ -n "$found" ]; then
echo "Device found."
else
echo "Device is not present."
zenity --error --text "Device is not present."
exit
fi
# restart the fucking menu
killall bluetooth-applet > /dev/null 2> /dev/null && bluetooth-applet &
# connect
zenity --info --text "Now please connect the device."
# restart the fucking menu
killall bluetooth-applet > /dev/null 2> /dev/null && bluetooth-applet &
# set sound output
index=`pacmd "list-sinks" | grep "index: [1-9]" | sed 's/\s*index:\s*//' | sed -e 's/\s*$//'`
pacmd "set-default-sink" "$index"
# start mocp
mocp -S
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment