Results 1 to 4 of 4

Thread: Need a script to restart bluetooth service.

  1. #1
    Join Date
    Aug 2007
    Beans
    10

    Need a script to restart bluetooth service.

    Hello,

    I am currently running Ubuntu 8.04 and have a little knowledge in linux. I would like to create a launcher or a small script to restart the bluetooth service. When I hit the Fn+2 key it shuts of the bluetooth signal but doesn't fully restart the service or maybe it just doesn't recreate the connection to my bluetooth device. When I execute this command: sudo /etc/init.d/bluetooth it does. I can do this but I would rather make a clickable icon to do this for the users I have.

    Please help!

  2. #2
    Join Date
    Mar 2009
    Beans
    1

    Re: Need a script to restart bluetooth service.

    I know that the command

    sudo /etc/init.d/servicename restart

    will restart most services. I tested this out with the bluetooth service, and it seemed to work. So try out

    sudo /etc/init.d/bluetooth restart

    Hope this helps!

  3. #3
    Join Date
    Dec 2006
    Beans
    1,133
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Need a script to restart bluetooth service.

    It is possible to run a script just by pressing the button or have it run because of some other hardware event. Unfortunately the details of this are beyond my experience at this time. I do know it is tied in with the files in /etc/acpi. These are scripts that run on events like open/close laptop lid, toggle wifi or bluetooth button, etc. Hope this info helps you find an answer.
    There are no dumb questions, just dumb answers.

  4. #4
    Join Date
    Mar 2007
    Location
    Singapore
    Beans
    10
    Distro
    Kubuntu 9.10 Karmic Koala

    Re: Need a script to restart bluetooth service.

    Hey, I wrote a GUI script for it

    It required zenity package so please install if you don't have it. You can add this script to desktop or panel as well.

    Download it, then
    % chmod +x bluezen

    On a side note, if you found the information box is annoying then remove this line " zenity --info --text "$STATUS" "

    Cheers,
    Idyllic Tux
    http://idyllictux.wordpress.com/

    Code:
    #!/bin/bash
    
    SWITCH=""
    PID=""
    # Comment out if your is toshiba laptop
    # TOSHSET=""
    
    SWITCH=$(zenity  --list  --text "Please Select Bluetooth Option:" --radiolist  --column " * " --column "Option" TRUE "On" FALSE "Off" FALSE "Restart" FALSE "Status");
    echo $SWITCH
    
    if [ $SWITCH = "On" ]; then
    	SWITCH="start"	
    	# Comment out if your is toshiba laptop
    	# TOSHSET="on"
    	bluetooth-applet &			
    elif [ $SWITCH = "Off" ]; then
    	SWITCH="stop"		
    	PID=$(pidof bluetooth-applet)
    	kill $PID
    elif [ $SWITCH = "Restart" ]; then
    	# Comment out if your is toshiba laptop
    	# TOSHSET="on"
    	SWITCH="restart"
    	PID=$(pidof bluetooth-applet)
    	kill $PID
    	bluetooth-applet &
    else 
    	#"Unknown parameter. Quitting."
    	SWITCH="status"
    fi
    
    ## Initialization
    STATUS=`gksudo /etc/init.d/bluetooth $SWITCH`
    zenity --info --text "$STATUS"
    # Comment out if your is toshiba laptop
    # gksudo toshset -bluetooth $TOSHSET
    Attached Files Attached Files

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
  •