1
0
mirror of https://github.com/danog/mklwp.git synced 2024-11-30 04:39:07 +01:00
mklwp/run.sh

158 lines
6.1 KiB
Bash
Raw Permalink 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-06-13 01:25:37 +02:00
2016-01-22 17:22:46 +01:00
[ "$1" = "bashbot" ] && {
2016-06-13 01:25:37 +02:00
error() { cd /mnt/vdb; rm -rf /mnt/vdb/$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; }
mktmpdir() { rm -rf /mnt/vdb/$1 &>/dev/null; cp -a $PWD /mnt/vdb/$1; cd /mnt/vdb/$1; }
2016-01-22 17:22:46 +01:00
echo "Custom LWP 2.6
Thanks : andrew121 for the app this script modifies
2016-06-13 01:25:37 +02:00
Thanks : olivvv59 for adding the # of images
Thanks : @danogentili for linux version and telegram bot (http://daniil.it)
2016-01-22 17:22:46 +01:00
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
2016-06-13 01:25:37 +02:00
wget "$icon" -qO placeimages/$(basename "$icon") && convert placeimages/$(basename "$icon") placeimages/icon.png && rm placeimages/$(basename "$icon") || 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 && {
2016-02-29 21:55:13 +01:00
screensize=$(identify "$size" | awk '{print $3}')
2016-01-23 17:19:32 +01:00
} || {
2016-02-29 21:55:13 +01:00
screensize="$size"
2016-01-23 17:19:32 +01:00
}
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
2016-02-29 21:55:13 +01:00
case "$answer" in
2016-01-22 17:22:46 +01:00
"1. A video")
2016-02-29 21:55:13 +01:00
echo "Send me the video itself or the video's url (I can download youtube videos)."
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-02-29 21:55:13 +01:00
basename="V.mp4"
2016-01-22 18:54:58 +01:00
echo "Downloading the video..."
2016-02-29 21:55:13 +01:00
youtube-dl "$video" -o $basename || error "couldn't download video"
2016-01-22 18:54:58 +01:00
echo "Getting frame number..."
2016-02-29 21:55:13 +01:00
frames=$(ffprobe -v error -count_frames -select_streams v:0 -show_entries stream=duration -of default=nokey=1:noprint_wrappers=1 $basename -loglevel panic)
frames=$(awk "BEGIN{print 1 / ($frames / 300)}")
2016-01-22 18:54:58 +01:00
echo "Converting video..."
2016-02-29 21:55:13 +01:00
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-06-13 01:25:37 +02:00
wget "$img" -qO placeimages/images/"$(basename "$img")" && convert placeimages/images/"$(basename "$img")" placeimages/images/n$n".png" && rm placeimages/images/"$(basename "$img")" && echo ok || error "couldn't download the image"
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")
2016-02-29 21:55:13 +01:00
echo "Converting images (might take up to five minutes)..."
2015-12-30 19:16:33 +01:00
n=0
2016-01-22 18:54:58 +01:00
p=0
2016-06-13 01:25:37 +02: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-02-29 21:55:13 +01:00
echo "Copying images..."
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-02-29 21:55:13 +01:00
echo "Editing configuration files..."
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.
2016-06-13 01:25:37 +02:00
Do check out my other projects @ https://daniil.it and do Check out my other bots: @video_dl_bot, @mklwp_bot, @caption_ai_bot, @cowsaysbot, @cowthinksbot, @figletsbot, @lolcatzbot, @filtersbot, @id3bot, @pwrtelegrambot!
2016-01-23 17:19:32 +01:00
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