Skip to content

Instantly share code, notes, and snippets.

@onesixromcom
Last active March 2, 2023 09:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onesixromcom/2a1f4257606d618e9cfbafd8d12f29f4 to your computer and use it in GitHub Desktop.
Save onesixromcom/2a1f4257606d618e9cfbafd8d12f29f4 to your computer and use it in GitHub Desktop.
Reconnect bluetooth headset for current active user (across mltiuser env)
#!/bin/sh
DEVICE_MAC='12:12:12:12:12:12'
bluetoothctl power on
bluetoothctl disconnect $DEVICE_MAC
bluetoothctl remove $DEVICE_MAC
bluetoothctl power off
bluetoothctl power on
sleep 5
bluetoothctl pairable on
bluetoothctl agent on
bluetoothctl default-agent
timeout 6s bluetoothctl scan on
# Here is error when turn off scaning.
bluetoothctl scan off
sudo killall pulseaudio
# start pulseaudio server immediatley from current user to make it's with the lowest id
systemctl --user start pulseaudio.service
bluetoothctl pair $DEVICE_MAC
bluetoothctl trust $DEVICE_MAC
bluetoothctl connect $DEVICE_MAC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment