[Android Apps and Games] dapaua:
Sample scripts

I'll post here all the included sample scripts, so you can see some examples:

BATTERY:

#INFO A simple battery widget

BAT=${NW_BATTERY}%

echo SETLAYOUT TEXT

echo SETTEXT $BAT

echo UPDATE

echo REFRESH 300

COUNTER:

#INFO A simple counter

# This line gets the variable counter from storage. If not defined, set to "0"

#GETVAR COUNTER 0

function refresh {

echo SETLAYOUT ICON_TEXT_ICON

echo SETICON LEFT 1

echo SETICON RIGHT 2

echo SETTEXT $COUNTER

echo UPDATE

echo STOREVAR COUNTER $COUNTER

}

if [[ $1 == "REFRESH" ]]; then

refresh

fi

if [[ $1 == "ICON1" ]]; then

COUNTER=$(($COUNTER-1))

refresh

fi

if [[ $1 == "ICON2" ]]; then

COUNTER=$(($COUNTER+1))

refresh

fi

ISSUNDAY:

#INFO Tells if today is sunday.

function refresh {

echo SETLAYOUT ICON_TEXT

DAY=`date "+%w"`

echo SETTEXT Loading...

echo UPDATE

if [[ DAY -eq 0 ]]; then

echo "SETTEXT Sunday"

echo SETICON OK

else

echo SETICON CROSS

echo "SETTEXT Not Sunday"

fi

echo UPDATE

echo REFRESH 3600

}

echo $1

if [[ $1 == "REFRESH" ]]; then

#This is caled when a refresh is needed.

refresh

fi

if [[ $1 == "ICON1" ]]; then

#This is called when icon1 is tapped

refresh

fi

if [[ $1 == "TEXT" ]]; then

#This is called when the text is tapped

refresh

fi

LAUNCHER:

#INFO A five icon launcher

APP1=com.whatsapp

APP2=com.google.android.gm

APP3=com.google.android.apps.maps

APP4=com.google.android.talk

APP5=com.android.vending

if [[ $1 == "REFRESH" ]]; then

echo SETLAYOUT 5ICON

echo SETAPPICON $APP1

echo SETAPPICON $APP2 2

echo SETAPPICON $APP3 3

echo SETAPPICON $APP4 4

echo SETAPPICON $APP5 5

echo UPDATE

echo REFRESH 3000

fi

if [[ $1 == "ICON1" ]]; then

echo RUNAPP $APP1

fi

if [[ $1 == "ICON2" ]]; then

echo RUNAPP $APP2

fi

if [[ $1 == "ICON3" ]]; then

echo RUNAPP $APP3

fi

if [[ $1 == "ICON4" ]]; then

echo RUNAPP $APP4

fi

if [[ $1 == "ICON5" ]]; then

echo RUNAPP $APP5

fi

PINGTEST:

#INFO Lets you know if you have internet connection

echo SETLAYOUT ICON_TEXT

echo SETTEXT Checking...

echo UPDATE

ping -c 1 www.google.com >/dev/null

OUT=$?

if [[ $OUT -eq 0 ]]; then

echo SETTEXT Connection OK

echo SETICON OK

else

echo SETTEXT "Can't connect"

echo SETICON CROSS

fi

echo UPDATE

echo REFRESH 120

TIME:

#INFO A simple clock

TIME=`date +%H:%M`

echo SETLAYOUT TEXT

echo SETTEXT $TIME

echo UPDATE

echo REFRESH 30

SCROLL_LAUNCHER12

#INFO A launcher with scroll - 12 icons

#GETVAR POSITION 0

# Now $POSITION HAS THE LAST POS.

APP[1]=com.whatsapp

APP[2]=com.google.android.gm

APP[3]=com.google.android.apps.maps

APP[4]=com.google.android.talk

APP[5]=com.android.vending

APP[6]=cat.ereza.apm

APP[7]=com.google.android.apps.authenticator2

APP[8]=com.android.chrome

APP[9]=com.dropbox.android

APP[10]=com.modoohut.dialer

APP[11]=com.dapaua.widgetsoverlay

APP[12]=nextapp.fx

# Set this to half the number of apps

NUM_APPS=6

# Set this to the number of columns, minus two

NUM_APP_ICONS=4

function set_apps {

# First row. It's apps 1,2,3 (4,5,6) ...

APP1=${APP[$(($POSITION))]}

APP2=${APP[$(($POSITION+1))]}

APP3=${APP[$(($POSITION+2))]}

APP4=${APP[$(($POSITION+3))]}

# Second row. It's apps 7,8,9 (10,11,12) ...

APP5=${APP[$(($POSITION+$NUM_APPS))]}

APP6=${APP[$(($POSITION+$NUM_APPS+1))]}

APP7=${APP[$(($POSITION+$NUM_APPS+2))]}

APP8=${APP[$(($POSITION+$NUM_APPS+3))]}

}

function refresh {

MAX_POS=$(($NUM_APPS-$NUM_APP_ICONS+1))

if [[ $POSITION -gt $MAX_POS ]] ; then

POSITION=$MAX_POS

fi

if [[ $POSITION -lt 1 ]] ; then

POSITION=1

fi

echo SETLAYOUT 12ICON

# Here I set the arrows

echo SETICON LEFT 1

echo SETICON RIGHT 6

echo SETICON BLANK 7

echo SETICON BLANK 12

#And now I set the eight apps.

set_apps

echo SETAPPICON $APP1 2

echo SETAPPICON $APP2 3

echo SETAPPICON $APP3 4

echo SETAPPICON $APP4 5

echo SETAPPICON $APP5 8

echo SETAPPICON $APP6 9

echo SETAPPICON $APP7 10

echo SETAPPICON $APP8 11

echo UPDATE

echo REFRESH 3000

#Store position, it may have changed.

echo STOREVAR POSITION $POSITION

}

if [[ $1 == "REFRESH" ]]; then

refresh

fi

if [[ $1 == "ICON2" ]]; then

set_apps

echo RUNAPP $APP1

fi

if [[ $1 == "ICON3" ]]; then

set_apps

echo RUNAPP $APP2

fi

if [[ $1 == "ICON4" ]]; then

set_apps

echo RUNAPP $APP3

fi

if [[ $1 == "ICON5" ]]; then

set_apps

echo RUNAPP $APP4

fi

if [[ $1 == "ICON8" ]]; then

set_apps

echo RUNAPP $APP5

fi

if [[ $1 == "ICON9" ]]; then

set_apps

echo RUNAPP $APP6

fi

if [[ $1 == "ICON10" ]]; then

set_apps

echo RUNAPP $APP7

fi

if [[ $1 == "ICON11" ]]; then

set_apps

echo RUNAPP $APP8

fi

if [[ $1 == "ICON1" ]]; then

POSITION=$(($POSITION-1))

refresh

fi

if [[ $1 == "ICON6" ]]; then

POSITION=$(($POSITION+1))

refresh

fi