Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect on Wake #12

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion disable_bluetooth.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash

blueutil --power 0

# Uncomment to debug
# echo "[$(date)] :attempting to disable bluetooth" >> ~/bluetooth.log
# echo "[$(date)] :attempting to disable bluetooth" >> ~/bluetooth.log
7 changes: 7 additions & 0 deletions enable_bluetooth.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#!/bin/bash
SLEEP_SCRIPTS_DIR=~/.sleepscripts

blueutil --power 1

# Go through PairedDevices.txt and connect
while read device; do
blueutil --connect $device &
done < ${SLEEP_SCRIPTS_DIR}/PairedDevices.txt

# Uncomment to debug
# echo "[$(date)] :attempting to enable bluetooth" >> ~/bluetooth.log
8 changes: 7 additions & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,22 @@ echo "***********************"
echo "Preparing sleep scripts"
echo "***********************"

# Create PairedDevices.txt file in KBOS directory - contains the list of paired devices
blueutil --paired | tr -d ',' | awk 'NR>0 { print $2 }' > PairedDevices.txt


# Determine and escape absolute paths of sleepwatcher and Blueutil
SLEEPWATCHER_PATH=$(which sleepwatcher | sed 's_/_\\/_g')
BLUEUTIL_PATH=$(which blueutil | sed 's_/_\\/_g')

# Copy sleepscripts to user directory
# Copy sleepscripts, PairedDevices.txt to user directory
mkdir -p ${SLEEP_SCRIPTS_DIR} || exit 1;
sed "s/blueutil/${BLUEUTIL_PATH}/" ./disable_bluetooth.sh > \
${SLEEP_SCRIPTS_DIR}/disable_bluetooth.sh || exit 1;
sed "s/blueutil/${BLUEUTIL_PATH}/" ./enable_bluetooth.sh > \
${SLEEP_SCRIPTS_DIR}/enable_bluetooth.sh || exit 1;
sed "s/blueutil/${BLUEUTIL_PATH}/" ./PairedDevices.txt > \
${SLEEP_SCRIPTS_DIR}/PairedDevices.txt|| exit 1;
chmod +x ${SLEEP_SCRIPTS_DIR}/* || exit 1;
echo "** sleep scripts copied to ${SLEEP_SCRIPTS_DIR}"

Expand Down