Quantcast
Channel: MobileRead Forums - PocketBook
Viewing all articles
Browse latest Browse all 1245

script to enable BT and launch audio apps

$
0
0
I use my PocketBook frequently to play audiobooks and occasionally to listen to MP3s (mainly background noise) whilst reading.
I regularly pair two different sets of BT headphones as well as my car stereo to the Pocketbook.
I find it cumbersome to use the PocketBook menu system to connect across these devices, so wrote a shell script to automate the procedure.
  • The script checks if BT is active, if not it will enable it.
  • The Bluetootth settings page is launched to allow a specific device to be paired.
  • A dialog box then prompts the user to launch the Audiobook or Media player app.
  • Once the audio app is closed, if the script enabled BT it will disable it.

Save the code below as a .app file in /mnt/ext1/applications if you'd like to try it. May need a device reboot before it shows in User's section of the app menu.
Spoiler:

Code:

#!/bin/sh

app=/ebrmain/cramfs/bin

function restore {
if [ $BT == 0 ]; then netagent bt off; fi
}
trap restore 0

if [ $(netagent bt status | grep -o BT_STATE_OFF) == BT_STATE_OFF ]; then
  BT=0; netagent bt on
else BT=1
fi

$app/settings.app -o bluetooth
$app/dialog 2 "" "Which Audio App?" "Audiobook" "MP3 Player" "Exit"; ans=$?
if [ $ans == 1 ]; then $app/audio_books.app
elif [ $ans == 2 ]; then $app/music_player.app
else exit
fi

exit 0


Viewing all articles
Browse latest Browse all 1245

Trending Articles