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


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:


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

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).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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