Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: HOWTO: A quick way to connect to your bluetooth headset

  1. #1
    Join Date
    Sep 2005
    Location
    Karlsruhe, Germany
    Beans
    86
    Distro
    Ubuntu 10.04 Lucid Lynx

    HOWTO: A quick way to connect to your bluetooth headset

    Hi!

    I think working with a bluetooth Headset is pretty annoying with linux. There's no way to quickly connect to your headset and get a visual feedback that the connection works. So here's a solution for that.

    A small script which enables the connection and shows a popup via libnotify on your desktop. It will look like like this.



    Please note: This won't help you to solve problems with your BT headset. You need a already configured bluetooth setup for this how-to. So before trying to do this how-to, make sure your setup is OK. For help how to do this, look e.g. here

    https://help.ubuntu.com/community/BluetoothSkype

    To get this working make sure libnotify-bin is installed on your system
    Code:
    sudo apt-get install libnotify-bin
    After that, you create the script
    Code:
    sudo gedit /usr/local/bin/headsetconnect
    and paste this content
    Code:
    #!/bin/bash
    
    # HeadsetConnect 1.0 connect by Chrissss
    # you need libnotify-bin to run this script
    
    # Enter the bluetooth address of your headset here
    MAC=xx:xx:xx:xx:xx:xx
    
    # Localisation
    TITLE="Bluetooth"
    CONNECTED="Connection to headset established."
    ALLREADYCONNECTED="Connection to headset already exists."
    FAILED="Connection to headset failed!"
    BTLOGO=/usr/share/icons/gnome/48x48/stock/io/stock_bluetooth.png
    
    # Now the magic
    PID=`pidof btsco`
    
    if [ ! $PID ]
    then
      btsco -v -s -f $MAC
      if [ -e /tmp/bt_headset_connected ]
      then
        notify-send -i $BTLOGO -t 3000 "$TITLE" "$CONNECTED"
      else
        notify-send -i gtk-dialog-warning -t 3000 "$TITLE" "$FAILED"
        killall btsco
      fi
    else
      notify-send  -u critical -i gtk-dialog-info -t 3000 "$TITLE" "$ALLREADYCONNEC
    fi
    Make sure to replace the "xx"s with the correct BT address of your headset. After that make the script executable
    Code:
    sudo chmod 755 /usr/local/bin/headsetconnect
    Well, you're done. Call
    Code:
    headsetconnect
    out of a terminal window, or even better, put a starter inside the gnome bar.

    CU
    Christoph

  2. #2
    Join Date
    Oct 2006
    Beans
    4

    Re: HOWTO: A quick way to connect to your bluetooth headset

    I think the script got cut off. Do you think you could attach it?

    blanny

  3. #3
    Join Date
    Aug 2005
    Location
    Durham, UK
    Beans
    16
    Distro
    The Feisty Fawn Testing

    Re: HOWTO: A quick way to connect to your bluetooth headset

    My new headset's still charging, so I haven't been able to try the script properly yet, but I think the only thing that got cut off was
    "$ALLREADYCONNEC
    to
    "$ALLREADYCONNECTED"

  4. #4
    Join Date
    Dec 2005
    Beans
    22

    Re: HOWTO: A quick way to connect to your bluetooth headset

    FYI, this isn't working reliably for me. It's much less slick (e.g. runs in foreground), but a script containing

    Code:
    sudo modprobe snd-bt-sco
    dbus-send --system --dest=org.bluez /org/bluez/hci0 org.bluez.Adapter.SetMode string:discoverable
    btsco -v  00:03:89:F1:7A:95
    does work reliably for me. I'd like to find a way to integrate the two.

  5. #5
    Join Date
    Mar 2007
    Location
    Texas, USA
    Beans
    58
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: HOWTO: A quick way to connect to your bluetooth headset

    How did you find the MAC address of your headset? In the SkypeBluetooth howto it says to use kbluetoothd. I couldn't find that in the repos, and i'm using gnome. any ideas?

  6. #6
    Join Date
    May 2006
    Beans
    Hidden!
    Distro
    Ubuntu Karmic Koala (testing)

    Re: HOWTO: A quick way to connect to your bluetooth headset

    Didn't know where else to post this but I made something similar. This script will search and display all available bluetooth devices and allow you to pick one. Works great for me, but theres only 3 BT devices in range so it needs some real-world testing.

    dependencies:

    Code:
    bluez-utils bluez-btsco zenity
    please run
    Code:
    sudo modprobe snd_bt_sco
    if you haven't already

    Code:
    #!/bin/bash
    killall btsco
    zenity --info --text="Click ok to search for your headset. Please ensure that your headset is in 'discoverable' mode."
    results=`hcitool scan`
    results=${results:13}
    declare -a macaddresses
    declare -a names
    i=1
    temp2=""
    
    while [ -n "$results" ]; do
    	temp=$results
    	macaddresses[$i]=${temp:0:18}
    	results=${results:18}
    	temp=${results%00:*}
    	names[$i]=$temp
    	results=${results:${#temp}}
    	i=$i+1;
    done
    
    if [ 0 -lt ${#macaddresses[@]} ]; then
    	address=`zenity --text="Please select your headset from the following list.\
    	\nIf your headset does not appear here click cancel." --list --column Address --column Name  ${macaddresses[1]} "${names[1]}"  ${macaddresses[2]} "${names[2]}"  ${macaddresses[3]} "${names[3]}"  ${macaddresses[4]} "${names[4]}"  ${macaddresses[5]} "${names[5]}"  ${macaddresses[6]} "${names[6]}"  ${macaddresses[7]} "${names[7]}"  ${macaddresses[8]} "${names[8]}"  ${macaddresses[9]} "${names[9]}"  ${macaddresses[10]} "${names[10]}" `
    	if [ -n "$address" ]; then
    		btsco -f -r -s $address
    		if [ -a /tmp/bt_headset_connected ]; then
    			zenity --info --text="Connection Successful!"
    		else
    			zenity --warning --text="Something's not right here, check the README and try again."
    		fi
    	else
    		zenity --warning --text="Please ensure you device is discoverable and restart this program to search again."
    	fi	
    else
    	zenity --warning --text="No bluetooth devices detected. Please ensure you device is discoverable and restart this program."
    fi
    Please criticize comment and bug-report, sorry if I'm stepping on toes Chrissss
    Last edited by Aetherius; May 14th, 2007 at 12:42 PM.
    "Kreed" - Download/File Server - AMD Sempron 3000+ / 768MB / nVidia 6200GT - Ubuntu 9.04
    "Muter" - Work Laptop - Dell Latitude D830 / Core 2 Duo 2.4GHz / 2048MB / Nvidia 140NVS - Ubutnu 9.04

  7. #7
    Join Date
    May 2007
    Beans
    17
    Distro
    Xubuntu 6.10 Edgy

    Re: HOWTO: A quick way to connect to your bluetooth headset

    I installed bluez-utils bluez-btsco zenity already.
    However, sudo modprobe btsco returns module not found.
    I also tried using module-assistant to search for btsco and cannot find it.

    Do I have to build that module somehow?

  8. #8
    Join Date
    May 2006
    Beans
    Hidden!
    Distro
    Ubuntu Karmic Koala (testing)

    Re: HOWTO: A quick way to connect to your bluetooth headset

    sorry

    Code:
    sudo modprobe snd_bt_sco

    my bad :corrected
    "Kreed" - Download/File Server - AMD Sempron 3000+ / 768MB / nVidia 6200GT - Ubuntu 9.04
    "Muter" - Work Laptop - Dell Latitude D830 / Core 2 Duo 2.4GHz / 2048MB / Nvidia 140NVS - Ubutnu 9.04

  9. #9
    Join Date
    May 2007
    Beans
    17
    Distro
    Xubuntu 6.10 Edgy

    Re: HOWTO: A quick way to connect to your bluetooth headset

    Actually, I also tried snd_bt_sco and still I cannot find the module.
    I did a quick google on it and found that
    For SCO (two-way voice quality audio) you need a kernel with the emu10k1 driver selected (this is one of the drivers that forces the inclusion of the implementation of "snd_hwdep_new")
    It also has somethng to do with ALSA I think.
    I'm using edgy with custom compiled 2.6.19 kernel. I might not have selected that.

    .. or maybe it's something else...

  10. #10
    Join Date
    Feb 2006
    Beans
    1,086
    Distro
    Ubuntu Gnome

    Re: HOWTO: A quick way to connect to your bluetooth headset

    Quote Originally Posted by hexo1125 View Post
    Actually, I also tried snd_bt_sco and still I cannot find the module.
    I did a quick google on it and found that


    It also has somethng to do with ALSA I think.
    I'm using edgy with custom compiled 2.6.19 kernel. I might not have selected that.

    .. or maybe it's something else...
    You have to make sure CONFIG_HWDEP_NEW is set (as you mentioned above) and compile the kernel module for your custom kernel. The source for this is included with the sources for btsco in a subdirectory called kernel.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •