LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   ACPI Script for bluetooth (https://www.linuxquestions.org/questions/slackware-14/acpi-script-for-bluetooth-540896/)

alkos333 03-26-2007 10:18 PM

ACPI Script for bluetooth
 
I wrote a little bluetooth script for acpi. It's run when a fn+f5 hotkey is pressed on the thinkpad:

Code:

#!/bin/bash

if grep "^status.*disabled" /proc/acpi/ibm/bluetooth
then
        echo 'enable' > /proc/acpi/ibm/bluetooth

        modprobe bluetooth
        modprobe l2cap
        modprobe hci_usb
        modprobe rfcomm

        rm /var/run/dbus/dbus.pid
        dbus-daemon --config-file=/etc/dbus-1/system.conf
        sdpd
        hcid

else
        echo 'disable' > /proc/acpi/ibm/bluetooth

        killall dbus-daemon
        killall sdpd
        killall hcid

        modprobe -r rfcomm
        modprobe -r hci_usb
        modprobe -r l2cap
        modprobe -r bluetooth

fi

exit 0


There is one problem with it. When the script is trying to do 'modprobe -r hci_usb', it says that the module is busy, but when I try to run the command manually right after the script was run, it works perfectly.

Any ideas what's going on?

H_TeXMeX_H 03-26-2007 11:18 PM

That's not the entire script is it ? There is a 'fi' after that right ? and perhaps an 'exit 0' too ?

Does it work to make a script that just runs 'modprobe -r hci_usb' ? Does it give you the same error, or just the sequence there ?

Code:

        modprobe -r rfcomm
        modprobe -r hci_usb
        modprobe -r l2cap
        modprobe -r bluetooth

does the order of these make a difference ?

As for echoing things into '/proc' ... I don't think it's a good idea :), but whatever you wanna do.

alkos333 03-26-2007 11:37 PM

Yeah, I created a test.sh with that one line and it works, but it won't work from within this script..

Yeah, I think I solved it. rfcomm and l2cap libs just don't have enough time to be removed first. I tried inserting a sleep statement before hci_usb and it worked.

H_TeXMeX_H 03-26-2007 11:42 PM

Try this:

Code:

while :
do
  if modprobe -r hci_usb
  then
    break 1
  fi
done



All times are GMT -5. The time now is 04:18 PM.