Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I would like to start / stop bluetooth service automatically when I turn on / off rfswitch, is that possible ?

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

Yes. Assuming you have udev, something like the following would be a decent start:

# /etc/udev/rules.d/10-rfkill.rules
SUBSYSTEM=="rfkill", ATTR{type}=="wlan", RUN+="/usr/local/bin/toggle-blue"

And then:

#!/bin/bash
#/usr/local/bin/toggle-blue

if [ ${RFKILL_STATE} = 2 -o ${RFKILL_STATE} = 0 ]; then
    (
    /etc/rc.d/bluetooth stop
    ) &
else
    (
    /etc/rc.d/bluetooth start
    ) &
fi

See the relevant man pages for more info ... you can do a lot with udev rules (although it can be a little overwhelming to learn).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.