Prevent hardware switch from enabling bluetooth
by boughtonp from LinuxQuestions.org on (#5EQ34)
I have a hardware radio switch. Unlike the various search results I'm finding, the switch works and is not itself a problem: If I turn if off, it disables wifi, and if I turn it on, it enables wifi.
What is happening that I do not want is having bluetooth re-enabled in software whenever the switch is turned on again, because it wasn't enabled before, (and I want it off at all times unless I explicitly request it).
In summary, given a current state of:
Code:$ sudo rfkill --output-all
ID TYPE DEVICE TYPE-DESC SOFT HARD
0 bluetooth tpacpi_bluetooth_sw Bluetooth blocked unblocked
2 wlan phy0 Wireless LAN unblocked unblocked[switch off]
Code:$ sudo rfkill --output-all
ID TYPE DEVICE TYPE-DESC SOFT HARD
0 bluetooth tpacpi_bluetooth_sw Bluetooth blocked blocked
2 wlan phy0 Wireless LAN blocked blocked[switch on]
Code:$ sudo rfkill --output-all
ID TYPE DEVICE TYPE-DESC SOFT HARD
0 bluetooth tpacpi_bluetooth_sw Bluetooth unblocked unblocked
2 wlan phy0 Wireless LAN unblocked unblocked
5 bluetooth hci0 Bluetooth blocked unblocked
It seems the correct behaviour should be to record the software state when the switch is turned off, then restore that state when the switch is toggled on, but I'm guessing that's a kernel level issue so even if I raised a bug and got agreement it would take time to filter through.
I don't want to have to manually run "sudo rfkill block bluetooth" to disable bluetooth - I either want that command performed automatically, or to disable bluetooth in such a way that it requires a manual action from me to turn back on.
Distro is Debian Buster.
In "/var/log/kern.log" there are the following entries caused by turning it off and on again:Code:Feb 26 16:33:47 mycomputer kernel: [ 997.411262] iwlwifi 0000:02:00.0: RF_KILL bit toggled to disable radio.
Feb 26 16:33:47 mycomputer kernel: [ 997.411265] iwlwifi 0000:02:00.0: reporting RF_KILL (radio disabled)
Feb 26 16:33:47 mycomputer kernel: [ 997.440882] iwlwifi 0000:02:00.0: RF_KILL bit toggled to disable radio.
Feb 26 16:33:50 mycomputer kernel: [ 1000.288581] iwlwifi 0000:02:00.0: RF_KILL bit toggled to enable radio.
Feb 26 16:33:50 mycomputer kernel: [ 1000.288586] iwlwifi 0000:02:00.0: reporting RF_KILL (radio enabled)I would like to set an event listener which reacts to the RF_KILL bit being toggled, but I'm having no luck finding any explanations as to if and how this can be done.
(I'm not interested in running a scheduled task; I want to react to the event immediately, or require manual intervention to turn on bluetooth.)
On the disabling front, I found a reference to AutoEnable in "/etc/bluetooth/main.conf" but changing that from true to false then restarting did not solve the problem.
Any ideas?


What is happening that I do not want is having bluetooth re-enabled in software whenever the switch is turned on again, because it wasn't enabled before, (and I want it off at all times unless I explicitly request it).
In summary, given a current state of:
Code:$ sudo rfkill --output-all
ID TYPE DEVICE TYPE-DESC SOFT HARD
0 bluetooth tpacpi_bluetooth_sw Bluetooth blocked unblocked
2 wlan phy0 Wireless LAN unblocked unblocked[switch off]
Code:$ sudo rfkill --output-all
ID TYPE DEVICE TYPE-DESC SOFT HARD
0 bluetooth tpacpi_bluetooth_sw Bluetooth blocked blocked
2 wlan phy0 Wireless LAN blocked blocked[switch on]
Code:$ sudo rfkill --output-all
ID TYPE DEVICE TYPE-DESC SOFT HARD
0 bluetooth tpacpi_bluetooth_sw Bluetooth unblocked unblocked
2 wlan phy0 Wireless LAN unblocked unblocked
5 bluetooth hci0 Bluetooth blocked unblocked
It seems the correct behaviour should be to record the software state when the switch is turned off, then restore that state when the switch is toggled on, but I'm guessing that's a kernel level issue so even if I raised a bug and got agreement it would take time to filter through.
I don't want to have to manually run "sudo rfkill block bluetooth" to disable bluetooth - I either want that command performed automatically, or to disable bluetooth in such a way that it requires a manual action from me to turn back on.
Distro is Debian Buster.
In "/var/log/kern.log" there are the following entries caused by turning it off and on again:Code:Feb 26 16:33:47 mycomputer kernel: [ 997.411262] iwlwifi 0000:02:00.0: RF_KILL bit toggled to disable radio.
Feb 26 16:33:47 mycomputer kernel: [ 997.411265] iwlwifi 0000:02:00.0: reporting RF_KILL (radio disabled)
Feb 26 16:33:47 mycomputer kernel: [ 997.440882] iwlwifi 0000:02:00.0: RF_KILL bit toggled to disable radio.
Feb 26 16:33:50 mycomputer kernel: [ 1000.288581] iwlwifi 0000:02:00.0: RF_KILL bit toggled to enable radio.
Feb 26 16:33:50 mycomputer kernel: [ 1000.288586] iwlwifi 0000:02:00.0: reporting RF_KILL (radio enabled)I would like to set an event listener which reacts to the RF_KILL bit being toggled, but I'm having no luck finding any explanations as to if and how this can be done.
(I'm not interested in running a scheduled task; I want to react to the event immediately, or require manual intervention to turn on bluetooth.)
On the disabling front, I found a reference to AutoEnable in "/etc/bluetooth/main.conf" but changing that from true to false then restarting did not solve the problem.
Any ideas?