-
Notifications
You must be signed in to change notification settings - Fork 1
/
sync_kiwi.tool
executable file
·61 lines (47 loc) · 1.55 KB
/
sync_kiwi.tool
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/data/data/com.termux/files/usr/bin/bash
# sync phone data with remote
set -e
notification_id="$RANDOM"
notification_title="Syncing jff.sh"
notification_content=()
remote="jff@jff.sh"
if ping -c 1 kiwi &>/dev/null; then
remote="jff@kiwi"
notification_title="Syncing kiwi"
fi
rsync_flags=( --progress --recursive --perms --times --owner --group --devices --specials --copy-links --verbose)
folders=(
dcim/Camera
dcim/MyAlbums
pictures/Messenger
)
update_notification(){
[[ "$1" ]] && notification_content+=("$1")
printf -v var "%s\n" "${notification_content[@]}"
echo "$var"
termux-notification \
--id "$notification_id" \
--icon cloud_sync \
--alert-once \
--title "$notification_title" \
--image-path ~/.toolbelt/powertools/toolicons/512x512/devices/computer-kiwi.png \
--content "$var"
}
update_notification "..."
notification_content=()
for folder in "${folders[@]}"; do
if [ -d ~/storage/"$folder" ]; then
update_notification "$folder"
rsync "${rsync_flags[@]}" --relative ~/storage/./"$folder" "$remote":backup/phone_jff/
else
update_notification "File not found: $folder"
fi
done
rsync_delete_flags=( --exclude '.config' --progress -av --delete )
update_notification "media/music"
rsync "${rsync_delete_flags[@]}" "$remote":.local/share/music/ ~/storage/music
termux-media-scan ~/storage/music
update_notification "wallpapers"
rsync "${rsync_delete_flags[@]}" "$remote":.local/share/wallpapers ~/.local/share
notification_title+=" Done"
update_notification