Skip to content

Instantly share code, notes, and snippets.

@Mnkai
Created November 28, 2017 13:43
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 Mnkai/ba022a4b5ae4d3113550f0060c8d123c to your computer and use it in GitHub Desktop.
Save Mnkai/ba022a4b5ae4d3113550f0060c8d123c to your computer and use it in GitHub Desktop.
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