Last active
September 11, 2021 15:04
-
-
Save midoriiro/320c6990ab8e66343a7b to your computer and use it in GitHub Desktop.
Bluetooth switcher in PyQt 5.5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
I've installed a new wifi card on my laptop with bluetooth support, | |
but there is no shortcut in my keyboard to swtich on/off bluetooth. | |
This script + custom shortcut with your linux DE (or other) work perfectly | |
''' | |
from PyQt5.QtCore import QCoreApplication | |
from PyQt5.QtBluetooth import QBluetoothLocalDevice | |
if __name__ == '__main__': | |
app = QCoreApplication(sys.argv) | |
local_device = QBluetoothLocalDevice() | |
if local_device.isValid(): | |
is_off = local_device.hostMode() == QBluetoothLocalDevice.HostPoweredOff or False | |
if is_off: | |
local_device.powerOn() | |
else: | |
local_device.setHostMode(QBluetoothLocalDevice.HostPoweredOff) | |
app.exit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment