1
0
mirror of https://github.com/danog/mklwp.git synced 2024-12-04 02:27:48 +01:00
mklwp/run.sh

151 lines
5.5 KiB
Bash
Raw Normal View History

2015-12-30 19:16:33 +01:00
#!/bin/bash
java -version &>/dev/null || { echo "Java is not installed. Please install java to run this tool"; exit 1; }
2016-01-22 16:03:47 +01:00
aapt &>/dev/null || export PATH="$PATH:$PWD/other"
2015-12-30 19:16:33 +01:00
rm -rf out &>/dev/null
2016-01-22 16:03:47 +01:00
2015-12-30 19:16:33 +01:00
cp -a other/backup out
2016-01-22 18:54:58 +01:00
first=$2
2016-01-22 17:22:46 +01:00
[ "$1" = "bashbot" ] && {
2016-01-25 13:23:06 +01:00
error() { cd /tmp; rm -rf /tmp/$first; echo "I'm sorry, it seems an error occurred ($*). Please type /start to restart the process. If you want you can report this error to the creator of this bot by sending a screenshot of this chat @danogentili"; sleep 2;exit; }
2016-01-22 18:54:58 +01:00
mktmpdir() { rm -rf /tmp/$1 &>/dev/null; cp -a $PWD /tmp/$1; cd /tmp/$1; }
2016-01-22 17:22:46 +01:00
echo "Custom LWP 2.6
Thanks : andrew121 for the app this script modifies
Thanks : olivvv59 for the added # of images
Thanks : danogentili for linux version and telegram bot (http://daniil.it)
Send me the app icon (preferrably square)."
2016-01-22 18:54:58 +01:00
mktmpdir $2 || error "couldn't create tmp dir"
2016-01-22 17:22:46 +01:00
read icon
convert $icon placeimages/icon.png || error "couldn't download icon"
2016-01-23 17:19:32 +01:00
2016-01-25 13:23:06 +01:00
echo "Send me your device's screen size (can be obtained using https://play.google.com/store/apps/details?id=lt.andro.screensize)."
2016-01-23 17:19:32 +01:00
read size
echo "$size" | grep -q http && {
screensize=$(identify $size | awk '{print $3}')
} || {
screensize=$size
}
2016-01-22 17:22:46 +01:00
weird=y
2016-01-22 18:54:58 +01:00
while [ "$weird" = "y" ];do
2016-01-22 17:22:46 +01:00
echo "Do you want to create this live wallpaper using mykeyboardstartshere \"1. A video\" \"2. Multiple images\""
read answer
case $answer in
"1. A video")
2016-01-22 18:54:58 +01:00
echo "Send me the video itself or the video's url."
2016-01-22 17:22:46 +01:00
read video
2016-01-23 17:19:32 +01:00
video=$(echo "$video" | sed 's/^\s*//g;s/\s*$//g')
2016-01-22 17:22:46 +01:00
basename=$(basename $video)
2016-01-22 18:54:58 +01:00
echo "Downloading the video..."
2016-01-23 17:19:32 +01:00
wget "$video" -qO $basename || error "couldn't download video"
2016-01-22 18:54:58 +01:00
echo "Getting frame number..."
frames=$(ffprobe -v error -count_frames -select_streams v:0 -show_entries stream=nb_read_frames -of default=nokey=1:noprint_wrappers=1 $basename -loglevel panic)
2016-01-22 17:22:46 +01:00
frames=$(awk "BEGIN{print $frames / 300}")
2016-01-22 18:54:58 +01:00
echo "Converting video..."
ffmpeg -i $basename -f image2 -r $frames placeimages/images/n%03d.png -loglevel panic || error "couldn't convert video"
2016-01-22 17:22:46 +01:00
rm $basename
2016-01-22 18:54:58 +01:00
echo "Done!"
2016-01-22 17:22:46 +01:00
weird=n
;;
"2. Multiple images")
echo "Send me the images, type done when you're done."
n=1
2016-01-22 18:54:58 +01:00
p=0
2016-01-22 17:22:46 +01:00
until [ "$n" = "301" ];do
read img
[ "${img,,}" = "done" ] && break
2016-01-22 18:54:58 +01:00
convert $img placeimages/images/n$n".png" && echo ok || error "couldn't download $img"
2016-01-22 17:22:46 +01:00
n=$(($n + 1))
done
weird=n
;;
esac
2016-01-22 18:54:58 +01:00
done
2016-01-22 17:22:46 +01:00
} || {
echo "Custom LWP 2.6
2015-12-30 19:16:33 +01:00
Thanks : andrew121 for the app this script modifies
Thanks : olivvv59 for the added # of images
Thanks : danogentili for linux version (http://daniil.it)
---------------------------------------------------
2016-01-22 17:22:46 +01:00
Place images in the placeimages/images folder and place the app icon in placeimages/icon.png
2015-12-30 19:16:33 +01:00
Make sure the images are the same resolution as your device for optimal results
You can use up to 300 images (n01.png...n300.png)
The images must be in png format.
2016-01-23 17:19:32 +01:00
Please enter your device's screen size (example: 1980x1280)."
read screensize
2016-01-22 17:22:46 +01:00
}
echo "Enter the name for this live wallpaper. This is shown in the lwp choice menu. "
read name
2015-12-30 19:16:33 +01:00
name=$(printf "%q" "$name")
2016-01-22 17:22:46 +01:00
echo "Enter the description for this live wallpaper. This is shown in the lwp choice menu. "
read desc
2015-12-30 19:16:33 +01:00
desc=$(printf "%q" "$desc")
2016-01-22 17:22:46 +01:00
echo "Enter the package name for this live wallpaper. This should be one word.
No spaces or fancy characters please. "
read pkgname
2015-12-30 19:16:33 +01:00
pkgname=$(printf "%q" "$pkgname")
n=0
2016-01-22 18:54:58 +01:00
p=0
2016-01-23 17:19:32 +01:00
for f in placeimages/images/*;do n=$(($n+1)); [ "$n" = 10 ] && p=; convert $f -resize $screensize "out/res/drawable-hdpi-v4/n"$p$n".png";done
2015-12-30 19:16:33 +01:00
n=$(printf "%x" $n)
2016-01-22 18:54:58 +01:00
counter=1
placeholder=0
2016-01-23 17:19:32 +01:00
screensize="s/480, 854/$(echo "$screensize" | sed 's/x/, /g')/g"
2016-01-22 18:54:58 +01:00
until [ $counter = 301 ]; do
[ ! -f "out/res/drawable-hdpi-v4/n$placeholder"$counter".png" ] && cp "other/ph.png" "out/res/drawable-hdpi-v4/n$placeholder"$counter".png"
counter=$(($counter + 1))
[ $counter = 10 ] && placeholder=
done
2016-01-23 17:19:32 +01:00
sed -i 's/suvbsib/'$pkgname'/g' out/smali/com/custom/lwp/suvbsib/*.smali out/res/xml/*.xml out/AndroidManifest.xml out/res/values/*.xml
sed -i "$screensize" out/smali/com/custom/lwp/suvbsib/*.smali out/res/xml/*.xml out/AndroidManifest.xml out/res/values/*.xml
2015-12-30 19:16:33 +01:00
mv out/smali/com/custom/lwp/suvbsib out/smali/com/custom/lwp/$pkgname
sed -i 's/appname/'$name'/g' out/AndroidManifest.xml
sed -i 's/dscrp/'$desc'/g' out/res/values/strings.xml
sed -i 's/const\/16 v1, 0x31/const\/16 v1, 0x'$n'/g' out/smali/com/custom/lwp/$pkgname/LiveWallpaperPainting\$OutRunEngine.smali
2016-01-22 18:54:58 +01:00
2016-01-22 16:03:47 +01:00
for f in out/res/drawable-*; do cp placeimages/icon.png $f;done
2015-12-30 19:16:33 +01:00
echo "
2016-01-23 17:19:32 +01:00
Building Apk..."
2015-12-30 19:16:33 +01:00
cd other
java -jar apktool.jar b ../out "$pkgname-unsigned.apk"
echo "
2016-01-23 17:19:32 +01:00
Signing Apk..."
2015-12-30 19:16:33 +01:00
java -jar signapk.jar -w testkey.x509.pem testkey.pk8 "$pkgname-unsigned.apk" "$pkgname-signed.apk"
rm "$pkgname-unsigned.apk"
cd ..
mv other/$pkgname-signed.apk $pkgname-signed.apk
echo "
Done.
"
2016-01-22 18:54:58 +01:00
[ "$1" != "bashbot" ] && {
2016-01-22 17:22:46 +01:00
read -p "Would you like to install this apk?
2015-12-30 19:16:33 +01:00
Ur device must be connected to ur pc and adb must be in ur PATH (y/n). " -n 1 -r
2016-01-22 17:22:46 +01:00
[[ $REPLY =~ ^[Yy]$ ]] && adb install -r $pkgname"-signed.apk"
echo
2016-01-22 18:54:58 +01:00
} || {
2016-01-25 13:23:06 +01:00
echo "This bot is based on https://github.com/topkecleon/telegram-bot-bash
You can also contribute to the development by sending a pull request @ https://github.com/danog/mklwp
2016-01-23 17:19:32 +01:00
Thanks for having used mklwp! To restart the process type /start.
Remember to set the correct resolution of your lwp by going in the lwp settings and setting the default resultion.
2016-01-25 13:23:06 +01:00
Sending apk...
2016-01-23 17:19:32 +01:00
There U go myfilelocationstartshere $PWD/$pkgname"-signed.apk
sleep 10
2016-01-22 18:54:58 +01:00
};
2015-12-30 19:16:33 +01:00
exit