Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > PocketBook > PocketBook Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 07-27-2023, 06:34 AM   #1
neil_swann80
0000000000101010
neil_swann80 ought to be getting tired of karma fortunes by now.neil_swann80 ought to be getting tired of karma fortunes by now.neil_swann80 ought to be getting tired of karma fortunes by now.neil_swann80 ought to be getting tired of karma fortunes by now.neil_swann80 ought to be getting tired of karma fortunes by now.neil_swann80 ought to be getting tired of karma fortunes by now.neil_swann80 ought to be getting tired of karma fortunes by now.neil_swann80 ought to be getting tired of karma fortunes by now.neil_swann80 ought to be getting tired of karma fortunes by now.neil_swann80 ought to be getting tired of karma fortunes by now.neil_swann80 ought to be getting tired of karma fortunes by now.
 
neil_swann80's Avatar
 
Posts: 5,459
Karma: 11226897
Join Date: Mar 2023
Location: An island off the coast of Ireland
Device: PB632 [HD3]
Browser launch script - enables WIFI etc

A script I use regularly on my HD3 (mileage may vary on other models)

The script will enable WIFI, connect to the last used network, test for an internet connection then launch the browser.

Once you've finished with the browser, closing it will cause the script to attempt to return the device's network state back to how it was at script launch, i.e. turn off WIFI etc.

* The script will not re-enable flight-mode if you're listening to an audiobook or music.

Code:
#!/bin/sh

# pocketbook system apps this script uses
browser=/ebrmain/cramfs/bin/browser.app
netagent=/ebrmain/cramfs/bin/netagent

# Exit function to restore original network conditions and browser settings
function restore {
 # if this script turned on WIFI, on exit turn off
 if [ "${wifi}" == "1" ]; then $netagent net off; fi
 # if this script turned off flight mode, checks for BT and turns off
 if [ "${flmode}" == "1" ]; then
   # BT on and connected - do nothing
   if [ -d "/sys/class/bluetooth/hci0/hci0:1" ]; then :
   # BT on and not connected
   elif [ -d "/sys/class/bluetooth/hci0" ]; then
     $netagent flightmode on
	 $netagent bt on
   # BT off
   else $netagent flightmode on
   fi
 fi
}
trap restore 0

# check flight mode off
if [ "$(netagent flightmode status)" == "flight mode = activated" ]; then
  flmode=1
  $netagent flightmode off
fi

# check wifi on
if [ ! -d "/sys/class/net/eth0" ]; then
  wifi=1
  $netagent net on
fi

dialog 1 "" "Connecting, please wait..." "" & sleep 1; kill "$!"

# check connected to wifi network - device connects to last used and available network
if [[ $(cat /sys/class/net/eth0/carrier) == 0 ]]; then
  sleep 5
  while [[ $(cat /sys/class/net/eth0/carrier) == 0 ]]; do
    dialog 5 "" "Still attempting to connect to a wireless network!  Wait?" "Yes" "No"
    if [ $? != 1 ]; then exit; fi
    $netagent connect
    sleep 3
  done
fi

# check internet connected
function internet {
  test="$(curl -Is  http://www.google.com | head -n 1)"
  test="${test:13:2}"
}
i=0
internet; if [ "$test" != "OK" ]; then
  sleep 3
  internet; while [ "$test" != "OK" ]; do
    let i++
    dialog 3 "" "No internet!  Wait?" "Yes" "No"
    if [ $? != 1 ]; then exit; fi
	# on third failed connection prompts to connect to different network
	if [ "$i" == "3" ]; then $netagent connect; fi
    sleep 3
	internet
  done
fi

$browser https://www.mobileread.com/forums

exit 0
Download HERE
neil_swann80 is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to launch the web browser from a script? [Kobo Start Menu] Mario Levrero Kobo Developer's Corner 1 04-12-2023 03:14 AM
cTorrent for Kindle 3. With Launch script. twobob Kindle Developer's Corner 2 09-17-2012 07:21 PM
Launch script on sytem events arikfunke Kindle Developer's Corner 0 04-21-2012 03:46 AM
iLiad Launch file from script dedo iRex Developer's Corner 3 07-21-2009 04:32 AM


All times are GMT -4. The time now is 06:52 PM.


MobileRead.com is a privately owned, operated and funded community.