Created
November 28, 2017 13:43
-
-
Save Mnkai/ba022a4b5ae4d3113550f0060c8d123c to your computer and use it in GitHub Desktop.
Example scripts to disable and enable bluetooth when sleeping
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 characters
#!/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 |
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 characters
[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 |
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 characters
#!/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