-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreadProfile.sh
More file actions
executable file
·100 lines (89 loc) · 2.63 KB
/
readProfile.sh
File metadata and controls
executable file
·100 lines (89 loc) · 2.63 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/zsh
source utils.sh
device="$1"
selected_file="$2"
profiles_path="$3"
file_path="$profiles_path/$selected_file"
if [ -z "$1" ]; then
echo "❌ Error: ADB device is not specified."
echo "Usage: $0 <adb_device> <json_file_name> <profiles_path>"
exit 13
fi
if [ -z "$2" ]; then
echo "❌ Error: JSON file name is not specified."
echo "Usage: $0 <adb_device> <json_file_name> <profiles_path>"
exit 14
fi
if [ -z "$3" ]; then
echo "❌ Error: Path to the profiles folder is not specified."
echo "Usage: $0 <adb_device> <json_file_name> <profiles_path>"
exit 15
fi
read_profile_on_keypress() {
trap handle_interrupt INT
update_count=0
read_profile_state="true"
while [[ "$read_profile_state" == "true" ]]; do
update_count=$((update_count + 1))
current_time=$(date "+%Y-%m-%d %H:%M:%S")
echo "-------------------------------"
bold_text "$(dim_text "Press Enter↵ key to fetch the current file content")"
bold_text "$(dim_text "or press Control⌃ + C to return to the menu.")"
echo
echo "📄 File path: $file_path"
echo "⏰ Last updated: $current_time"
echo "🔁 Update count: $update_count"
echo
adb -s "$device" shell "cat $file_path" | jq .
dd bs=1 count=1 >/dev/null 2>&1
done
}
read_profile_with_interval() {
trap handle_interrupt INT
update_count=0
read_profile_state="true"
while [[ "$read_profile_state" == "true" ]]; do
update_count=$((update_count + 1))
current_time=$(date "+%Y-%m-%d %H:%M:%S")
echo "-------------------------------"
bold_text "$(dim_text "Press Control⌃ + C to return to the menu.")"
echo
echo "📄 File path: $file_path"
echo "🔃 Refresh interval: $interval seconds"
echo "⏰ Last updated: $current_time"
echo "🔁 Update count: $update_count"
echo
adb -s "$device" shell "cat $file_path" | jq .
sleep "$interval"
done
}
handle_interrupt() {
trap - INT
stty sane
read_profile_state="false"
echo
echo "👋 Returning to the Menu..."
sleep 0.5
$command_to_run
}
echo "-------------------------------"
echo "📝 Press Enter↵ to update the profile content manually by pressing key"
echo -n "\033[3mOr enter a refresh interval in seconds for automatic updates: \033[0m"
read user_input
if [[ -z "$user_input" ]]; then
interval=0
clear
echo
read_profile_on_keypress
elif [[ "$user_input" =~ ^[0-9]+$ ]] && [ "$user_input" -gt 0 ]; then
interval=$user_input
clear
echo
read_profile_with_interval
else
echo
echo "❌ Error: Invalid input. Please enter update interval in seconds or leave empty for manual mode."
wait_for_any_key
clear
./chooseProfile.sh "$device"
fi