Skip to content

Instantly share code, notes, and snippets.

@mireq
Last active March 24, 2019 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mireq/9d97cdef0df16522dcc5e74c2cf9057a to your computer and use it in GitHub Desktop.
Save mireq/9d97cdef0df16522dcc5e74c2cf9057a to your computer and use it in GitHub Desktop.
Script to install amazfit bip watch face from amazfitwatchfaces.com
#!/bin/bash
# USAGE: bash install_bip_skin.sh https://amazfitwatchfaces.com/bip/view/id [version]
# bash install_bip_skin.sh https://amazfitwatchfaces.com/bip/view/8992 5b32bd
watchface_dir=/sdcard/Android/data/com.xiaomi.hm.health/files/watch_skin_local
mkdir -p tmp
curl $1 > tmp/amazfit.html 2> /dev/null
preview=`cat tmp/amazfit.html|grep '<meta property="og:image"'|head -n 1|tr -d '\r'|sed -e 's/.*content="\([^"]*\)".*/\1/g'`
preview_basename=`basename $preview`
if [[ -z "$preview" ]]; then
echo "Preview"
exit -1
fi
if [[ -z "$2" ]]; then
download=`cat tmp/amazfit.html|grep "/do/dl?dir=bin&file="|head -n 1|tr -d '\r'`
else
download=`cat tmp/amazfit.html|grep "/do/dl?dir=bin&file="|grep ">.*$2.*<"|head -n 1|tr -d '\r'`
fi
if [[ -z "$download" ]]; then
echo "Watch face not found"
exit -1
fi
basename=`echo $download|sed -e 's/.*>\(.*\)\.bin<\/a>/\1/g'`
dl_url=`echo $download|sed -e 's/.*href="\([^"]*\)".*/\1/g'`
mkdir -p "tmp/$basename"
curl "https://amazfitwatchfaces.com$dl_url" > "tmp/$basename/$basename.bin" 2> /dev/null | exit -2
curl "https:$preview" > "tmp/$basename/$preview_basename" 2> /dev/null | exit -2
printf '\x0F\x00\xEE\x00\x00\x00\x39\x60'|dd of="tmp/$basename/$basename.bin" bs=1 seek=16 count=8 conv=notrunc 2> /dev/null| exit -3
adb shell mkdir -p $watchface_dir | exit -4
adb push "tmp/$basename" $watchface_dir | exit -4
rm -f tmp/amazfit.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment