Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
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:


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

share|improve this answer

Your Answer


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.