Last active
July 6, 2019 22:27
-
-
Save ralt/b25095dcc1be680e581a9a53f2edcb43 to your computer and use it in GitHub Desktop.
Revisions
-
ralt revised this gist
Jul 6, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -52,7 +52,7 @@ gevent.monkey.patch_all() import subprocess import time import gevent def _refresh(device): -
ralt revised this gist
Jul 6, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ # out how. Apparently I need to register to 2 or 3 bug trackers? I may # just be dense. # To be able to run this hack, you need: bluez (which provides the # bluetoothctl binary) and python3-gevent. # Source: https://gist.github.com/ralt/b25095dcc1be680e581a9a53f2edcb43 -
ralt revised this gist
Jul 6, 2019 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -23,8 +23,8 @@ set -e # Start with checking the requirements. python3 -c 'import gevent' &> /dev/null || echo 'You need python3-gevent' && exit 1 which bluetoothctl &> /dev/null || echo 'You need bluez (for bluetoothctl)' && exit 1 # And now the fun begins. cd ~ -
ralt revised this gist
Jul 6, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -22,7 +22,7 @@ set -e # Start with checking the requirements. python3 -c 'import gevent' which bluetoothctl -
ralt revised this gist
Jul 6, 2019 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -26,8 +26,10 @@ set -e python3 -c 'import gevent' which bluetoothctl # And now the fun begins. cd ~ # Create a systemd user service for our hack. cat > .config/systemd/user/fix-bluetooth.service <<EOF [Unit] Description=Fix bluetooth @@ -39,6 +41,7 @@ ExecStart=/home/$USER/bin/fix-bluetooth WantedBy=default.target EOF # Now put the hack in the ~/bin folder. mkdir -p bin cat > bin/fix-bluetooth <<EOF #!/usr/bin/env python3 @@ -94,7 +97,9 @@ if __name__ == "__main__": time.sleep(60) EOF # Don't forget this or you look stupid. chmod +x bin/fix-bluetooth # Finally, enable and start our systemd user service. systemctl --user enable fix-bluetooth systemctl --user start fix-bluetooth -
ralt revised this gist
Jul 6, 2019 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -22,6 +22,10 @@ set -e # Start with checking the requirements: python3 -c 'import gevent' which bluetoothctl cd ~ cat > .config/systemd/user/fix-bluetooth.service <<EOF -
ralt revised this gist
Jul 6, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -18,7 +18,7 @@ # bluetoothctl binary) and python3-gevent. # Source: https://gist.github.com/ralt/b25095dcc1be680e581a9a53f2edcb43 # License: MIT (is that even needed for such a small amount of code?) set -e -
ralt revised this gist
Jul 6, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -18,7 +18,7 @@ # bluetoothctl binary) and python3-gevent. # Source: https://gist.github.com/ralt/b25095dcc1be680e581a9a53f2edcb43 # License: WTFPL (is that even needed for such a small amount of code?) set -e -
ralt revised this gist
Jul 6, 2019 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -17,6 +17,9 @@ # To be able to run this fix, you need: bluez (which provides the # bluetoothctl binary) and python3-gevent. # Source: https://gist.github.com/ralt/b25095dcc1be680e581a9a53f2edcb43 # License: WTFPL set -e cd ~ -
ralt revised this gist
Jul 6, 2019 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -19,6 +19,8 @@ set -e cd ~ cat > .config/systemd/user/fix-bluetooth.service <<EOF [Unit] Description=Fix bluetooth -
ralt revised this gist
Jul 6, 2019 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -17,6 +17,8 @@ # To be able to run this fix, you need: bluez (which provides the # bluetoothctl binary) and python3-gevent. set -e cat > .config/systemd/user/fix-bluetooth.service <<EOF [Unit] Description=Fix bluetooth -
ralt revised this gist
Jul 6, 2019 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -28,6 +28,7 @@ ExecStart=/home/$USER/bin/fix-bluetooth WantedBy=default.target EOF mkdir -p bin cat > bin/fix-bluetooth <<EOF #!/usr/bin/env python3 -
ralt revised this gist
Jul 6, 2019 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,8 @@ #!/usr/bin/env bash # This shell script setups bluetooth to be flawless in gnome shell. # Devices are now instantly connected when they're near the laptop. # (It probably works as a service for random WMs too.) # The issue is essentially that gnome-bluetooth is issuing the wrong # dbus calls to connect the device immediately; org.bluez gets EAGAIN -
ralt renamed this gist
Jul 6, 2019 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,6 @@ #!/usr/bin/env bash # This shell script setups bluetooth to be flawless. # Devices are now instantly connected when they're near the laptop. # The issue is essentially that gnome-bluetooth is issuing the wrong -
ralt revised this gist
Jul 6, 2019 . 1 changed file with 10 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # This shell scripts setups bluetooth to be flawless. # Devices are now instantly connected when they're near the laptop. # The issue is essentially that gnome-bluetooth is issuing the wrong @@ -14,17 +14,18 @@ # To be able to run this fix, you need: bluez (which provides the # bluetoothctl binary) and python3-gevent. cat > .config/systemd/user/fix-bluetooth.service <<EOF [Unit] Description=Fix bluetooth [Service] ExecStart=/home/$USER/bin/fix-bluetooth [Install] WantedBy=default.target EOF cat > bin/fix-bluetooth <<EOF #!/usr/bin/env python3 import gevent.monkey @@ -77,7 +78,8 @@ if __name__ == "__main__": time.sleep(60) EOF chmod +x bin/fix-bluetooth systemctl --user enable fix-bluetooth systemctl --user start fix-bluetooth -
ralt revised this gist
Jul 6, 2019 . 1 changed file with 7 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ # To be able to run this fix, you need: bluez (which provides the # bluetoothctl binary) and python3-gevent. ralt@zap:~/ -> cat > .config/systemd/user/fix-bluetooth.service <<EOF [Unit] Description=Fix bluetooth @@ -23,7 +23,8 @@ ExecStart=/home/ralt/bin/fix-bluetooth [Install] WantedBy=default.target EOF ralt@zap:~/ -> cat > bin/fix-bluetooth <<EOF #!/usr/bin/env python3 import gevent.monkey @@ -75,6 +76,8 @@ if __name__ == "__main__": del refreshers[device] time.sleep(60) EOF ralt@zap:~/ -> chmod +x bin/fix-bluetooth ralt@zap:~/ -> systemctl --user enable fix-bluetooth Created symlink /home/ralt/.config/systemd/user/default.target.wants/fix-bluetooth.service → /home/ralt/.config/systemd/user/fix-bluetooth.service. ralt@zap:~/ -> systemctl --user start fix-bluetooth -
ralt revised this gist
Jul 6, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,7 @@ # meantime, this hack lets me have a seamless bluetooth experience. # PS: I tried to report the bug to gnome-bluetooth but haven't figured # out how. Apparently I need to register to 2 or 3 bug trackers? I may # just be dense. # To be able to run this fix, you need: bluez (which provides the # bluetoothctl binary) and python3-gevent. -
ralt revised this gist
Jul 6, 2019 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,8 @@ # out how. Apparently I need to register to 2 or 3 bug trackers? I may # be just dense. # To be able to run this fix, you need: bluez (which provides the # bluetoothctl binary) and python3-gevent. ralt@zap:~/ -> cat .config/systemd/user/fix-bluetooth.service [Unit] -
ralt revised this gist
Jul 6, 2019 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -11,6 +11,8 @@ # out how. Apparently I need to register to 2 or 3 bug trackers? I may # be just dense. # To be able to run this fix, you need: bluetoothctl and python3-gevent. ralt@zap:~/ -> cat .config/systemd/user/fix-bluetooth.service [Unit] Description=Fix bluetooth -
ralt revised this gist
Jul 6, 2019 . No changes.There are no files selected for viewing
-
ralt revised this gist
Jul 6, 2019 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,6 @@ # This shell session explains how to setup bluetooth to be flawless. # Devices are now instantly connected when they're near the laptop. # The issue is essentially that gnome-bluetooth is issuing the wrong # dbus calls to connect the device immediately; org.bluez gets EAGAIN # from the kernel when it processes gnome-bluetooth dbus calls (until -
ralt revised this gist
Jul 6, 2019 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,10 +2,10 @@ # Devices are immediately connecting when they're near the laptop. # The issue is essentially that gnome-bluetooth is issuing the wrong # dbus calls to connect the device immediately; org.bluez gets EAGAIN # from the kernel when it processes gnome-bluetooth dbus calls (until # it eventually succeeds, 20-30s later). However, bluetoothctl is # flawless at it. Maybe some day gnome-bluetooth will fix this. In the # meantime, this hack lets me have a seamless bluetooth experience. # PS: I tried to report the bug to gnome-bluetooth but haven't figured # out how. Apparently I need to register to 2 or 3 bug trackers? I may # be just dense. -
ralt renamed this gist
Jul 6, 2019 . 1 changed file with 9 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,14 @@ # This shell session explains how to setup bluetooth to be flawless. # Devices are immediately connecting when they're near the laptop. # The issue is essentially that gnome-bluetooth is issuing the wrong # dbus calls to connect the device immediately; org.bluez gets EAGAIN # from the kernel when it processes gnome-bluetooth dbus calls. However, # bluetoothctl is flawless at it. Maybe some day gnome-bluetooth will # fix this. In the meantime, this hack lets me have a seamless bluetooth # experience. # PS: I tried to report the bug to gnome-bluetooth but haven't figured # out how. Apparently I need to register to 2 or 3 bug trackers? I may # be just dense. ralt@zap:~/ -> cat .config/systemd/user/fix-bluetooth.service [Unit] -
ralt revised this gist
Jul 6, 2019 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,7 @@ # This shell session explains how to setup bluetooth to be flawless. # Devices are immediately connecting when they're near the laptop. # The issue is essentially that gnome-bluetooth is issuing the wrong dbus calls to connect the device immediately; org.bluez gets EAGAIN from the kernel when it processes gnome-bluetooth dbus calls. However, bluetoothctl is flawless at it. Maybe some day gnome-bluetooth will fix this. In the meantime, this hack lets me have a seamless bluetooth experience. # PS: I tried to report the bug to gnome-bluetooth but haven't figured out how. Apparently I need to register to 2 or 3 bug trackers? I may be just dense. ralt@zap:~/ -> cat .config/systemd/user/fix-bluetooth.service [Unit] -
ralt created this gist
Jul 6, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,67 @@ # This shell session explains how to setup bluetooth to be flawless. # Devices are immediately connecting when they're near the laptop. ralt@zap:~/ -> cat .config/systemd/user/fix-bluetooth.service [Unit] Description=Fix bluetooth [Service] ExecStart=/home/ralt/bin/fix-bluetooth [Install] WantedBy=default.target ralt@zap:~/ -> cat bin/fix-bluetooth #!/usr/bin/env python3 import gevent.monkey gevent.monkey.patch_all() import subprocess import time import gevent.pool def _refresh(device): while True: try: subprocess.check_call(["bluetoothctl", "connect", device]) except subprocess.CalledProcessError: time.sleep(1) else: time.sleep(10) if __name__ == "__main__": refreshers = {} while True: out = subprocess.check_output(["bluetoothctl", "devices"]) devices = [] for line in out.splitlines(): try: _, device, _ = line.split(b" ", 2) except ValueError: continue devices.append(device) for device in devices: if device not in refreshers: print("Taking care of device: {}".format(device)) refreshers[device] = gevent.spawn(_refresh, device) delete = [] for device in refreshers: if device not in devices: print("Forgetting about device: {}".format(device)) refreshers[device].kill() delete.append(device) for device in delete: del refreshers[device] time.sleep(60) ralt@zap:~/.config/systemd/user/ -> systemctl --user enable fix-bluetooth Created symlink /home/ralt/.config/systemd/user/default.target.wants/fix-bluetooth.service → /home/ralt/.config/systemd/user/fix-bluetooth.service. ralt@zap:~/.config/systemd/user/ -> systemctl --user start fix-bluetooth