Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Example scripts to disable and enable bluetooth when sleeping
#!/bin/bash
ID="-1"
ID=$(echo $(rfkill | grep bluetooth) | cut -f1 -d " ")
if [ "$ID" == "-1" ]; then
exit -1
else
rfkill block $ID
rmmod btusb -f
fi
[Unit]
Description=Bluetooth pause resume when sleep
Before=sleep.target
StopWhenUnneeded=yes
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/opt/block_bluetooth.sh
ExecStop=/opt/unblock_bluetooth.sh
[Install]
WantedBy=sleep.target
#!/bin/bash
ID="-1"
ID=$(echo $(rfkill | grep bluetooth) | cut -f1 -d " ")
if [ "$ID" == "-1" ]; then
exit -1
else
modprobe btusb
rfkill unblock $ID
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment