-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathsysinfo
More file actions
executable file
·845 lines (744 loc) · 23.9 KB
/
Copy pathsysinfo
File metadata and controls
executable file
·845 lines (744 loc) · 23.9 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
#!/data/data/com.termux/files/usr/bin/bash
# Author: Abdul Jaber(Aj-Seven)
# Github: @Aj-Seven
# Reddit: @A_J07
#color codes
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
YELLOW=$(tput setaf 3)
BLUE=$(tput setaf 4)
MAGENTA=$(tput setaf 5)
CYAN=$(tput setaf 6)
WHITE=$(tput setaf 7)
RESET=$(tput sgr0)
#text formatting
BOLD=$(tput bold)
UNDERLINE=$(tput smul)
NO_UNDERLINE=$(tput rmul)
#store repo info
REPO_DIR="$PREFIX/share/Android-Sysinfo"
SCRIPT_NAME="sysinfo"
REPO_URL="https://github.com/Aj-Seven/Android-Sysinfo"
BIN_DIR="$PREFIX/bin"
# Function to print texts
PRINT() {
local style=$1
local color=$2
local message=$3
echo -e "${style}${color}${message}${RESET}"
}
# Function to update the repository
update_repo() {
cd "$REPO_DIR" || exit 1
# Run git pull origin and parse the output to show only relevant lines
if output=$(git pull origin $(git rev-parse --abbrev-ref HEAD) 2>&1); then
if echo "$output" | grep -q 'Already up to date'; then
echo "up-to-date"
elif echo "$output" | grep -q 'Updating'; then
echo "updated"
PRINT "
$BOLD$YELLOW Updated the script, start it again to apply changes..."
exit 0
else
echo "Failed"
fi
fi
}
# Function to check for updates in the repository
monitor_update() {
# Check if the repository folder exists
if [ ! -d "$REPO_DIR" ]; then
git clone "$REPO_URL" "$REPO_DIR" > /dev/null 2>&1 || { UPDATE_STATUS="failed"; return; }
fi
# Fetch updates forcefully
cd "$REPO_DIR" || { UPDATE_STATUS="failed"; return; }
git fetch --force origin > /dev/null 2>&1
# Get the current branch
current_branch=$(git rev-parse --abbrev-ref HEAD)
# Check if the local branch is behind the remote branch
if [ $(git rev-list HEAD...origin/$current_branch --count) -gt 0 ]; then
return 0
else
return 1
fi
}
# Function to check the termux api android pkg availabity
check_termux_api() {
# Capture the output and check if the string "Error: Not found" exists
local status=$(termux-api-start 2>&1 | grep -o "Error: Not found")
# Compare the status with the string "Error: Not found"
if [ "$status" == "Error: Not found" ]; then
return 0
else
return 1
fi
}
# Function to check from termux_api and prompt request for installation
termux_api_with_prompt_setup() {
if check_termux_api; then
clear
PRINT $BOLD"$RED Please Install termux-api in your device, to run this option$RESET
$BLUE Visit here: $GREEN https://f-droid.org/en/packages/com.termux.api/$RESET
$BOLD$WHITE Do you want to visit the site?? Enter Y"
read visit
if [[ $visit == "Y" ]] || [[ $visit == "y" ]]; then
xdg-open https://f-droid.org/en/packages/com.termux.api/
else
main
fi
fi
}
#check update function for menu selection
check_update() {
clear
cd "$REPO_DIR" || { UPDATE_STATUS="failed"; return; }
git fetch --force origin > /dev/null 2>&1
current_branch=$(git rev-parse --abbrev-ref HEAD)
if [ $(git rev-list HEAD...origin/$current_branch --count) -gt 0 ]; then
clear
PRINT "
$BOLD$GREEN Updates Available :)\n"
read -p "Do you want to update it?(Y/N) " select
case $select in
Y|y) update_repo
;;
N|n)
PRINT "
$BOLD$YELLOW Returning to main Menu"
UPDATE_STATUS=$(monitor_update)
main
;;
*)
PRINT "
$BOLD$YELLOW INFO:$RESET Invalid Selection, Select options in Between Y/N..."
;;
esac
else
PRINT "
$BOLD$CYAN Already Up-to-date."
PRINT "
$BOLD$YELLOW INFO:$RESET Press 'Enter' or any key to return main menu..."
read -r
fi
}
#Function to check whether ADB remote tcp is open or not.
check_adb_port() {
local state=$(nmap -p 5555 127.0.0.1)
if echo "$state" | grep -q "open"; then
return 0
else
return 1
fi
}
#Function to connect ADB to the device
connect_adb() {
adb connect 127.0.0.1:5555 >/dev/null 2>&1
}
#Function to run adb shell command within localhost port to avoid conflicts
run-shell() {
adb -s 127.0.0.1:5555 shell "$@"
}
#spinner function
spinner() {
local message=$1
local pid=$2
local delay=0.1
local colors=("31;5")
local spinstr='⣾⣽⣻⢿⡿⣟⣯⣷'
local i=0
tput civis
while ps -p $pid > /dev/null; do
local color=${colors[i++ % ${#colors[@]}]}
printf "\e[${color}m%s\e[0m" "${spinstr:i++%${#spinstr}:1}"
sleep $delay
printf "\b"
done
tput cnorm
printf " \b\b\b"
}
memusage() {
clear
get_memory_info() {
local mem_info=$(free -m | awk '/Mem/ {print}')
TOTAL_MEM=$(awk '{print $2}' <<< "$mem_info")
AVAILABLE_MEM=$(awk '{print $7}' <<< "$mem_info")
TOTAL_USED_MEM=$(( TOTAL_MEM - AVAILABLE_MEM ))
BUFFCACHE_MEM=$(awk '{print $6}' <<< "$mem_info")
FREE_BUFF_MEM=$(awk '{print $4}' <<< "$mem_info")
PERCENT_USED_MEM=$(awk 'NR==2{printf "%.2f%%", $3*100/$2 }' <<< "$(free -m)")
}
print_memory_details() {
PRINT $BOLD"
$CYAN Total Memory: $WHITE $TOTAL_MEM MB
$CYAN Used Memory: $WHITE $TOTAL_USED_MEM MB
$CYAN Available Memory: $WHITE $AVAILABLE_MEM MB
$CYAN Buffer+Cache Memory: $WHITE $BUFFCACHE_MEM MB
$CYAN Free Buff+Cache Memory: $WHITE $FREE_BUFF_MEM MB
$CYAN Percentage Usage: $WHITE $PERCENT_USED_MEM"
}
get_memory_info
PRINT $BOLD"
$UNDERLINE$MAGENTA Memory Details:$RESET"
print_memory_details
PRINT "
$YELLOW$BOLD INFO:$RESET Press 'l' for Live Monitoring...
$YELLOW$BOLD INFO:$RESET Press 'Enter' or any key to Quit."
read -n 1 key
if [[ $key = "l" ]]; then
clear
while true; do
tput cup 0
tput el
get_memory_info
PRINT $BOLD"
$UNDERLINE$MAGENTA Memory Live Monitoring:$RESET"
print_memory_details
PRINT "
$YELLOW$BOLD INFO:$RESET Press 'Enter' or any key to Quit."
sleep 1
read -n 1 -s -t 1 && break
done
fi
}
#CPU Information
cpu() {
clear
cpu_info() {
data=$(lscpu)
name=$(echo "$data" | grep "Vendor ID" | awk '{print $3}')
model=$(getprop ro.soc.model)
arch=$(echo "$data" | grep "Architecture" | awk '{print $2}')
cores=$(grep -c "^processor" /proc/cpuinfo)
governor=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
order=$(echo "$data" | awk '/Byte Order/ {for (i=3; i<=NF; i++) printf "%s ", $i}')
op_modes=$(echo "$data" | awk '/CPU op-mode\(s\)/ {print $(NF-1), $NF}')
features=$(awk '/Features/ && !flag {sub(/^[[:space:]]*Features[[:space:]]*:[[:space:]]*/, ""); print; flag=1}' /proc/cpuinfo)
model_names=$(echo "$data" | awk '/Model name/ {for (i=3; i<=NF; i++) printf "%s ", $i}')
min_max_values=$(echo "$data" | awk '/CPU (min|max) MHz:/ {print $NF}')
scaling_percentages=$(echo "$data" | grep -oP 'CPU\(s\) scaling MHz:\s+\K\d+%')
vulnerabilities=$(echo "$data" | grep -E "Vulnerability|bugs" | awk '/Vulnerability/ {gsub("Vulnerability ", ""); print $0}')
abi=$(getprop ro.product.cpu.abi)
s_abi=$(getprop ro.product.cpu.abilist)
# Number of CPUs
num_cpus=$(echo "$model_names" | wc -l)
PRINT "$BOLD
$CYAN Name: $WHITE $name
$CYAN Model: $WHITE $model
$CYAN Architecture: $WHITE $arch
$CYAN Operation Mode: $WHITE $op_modes
$CYAN No. of Cores: $WHITE $cores
$CYAN Governor: $WHITE $governor
$CYAN ABI: $WHITE $abi
$CYAN Supported ABIs: $WHITE $s_abi
$CYAN Byte Order: $WHITE $order
$CYAN Model name: $WHITE $(echo "$model_names" | awk NR==1)
$CYAN Min MHz: $WHITE $(echo "$min_max_values" | awk NR==2) $(echo "$min_max_values" | awk NR==4)
$CYAN Max MHz: $WHITE $(echo "$min_max_values" | awk NR==1) $(echo "$min_max_values" | awk NR==3)
$CYAN Max Scaling: $WHITE $(echo "$scaling_percentages" | awk NR==1) $(echo "$scaling_percentages" | awk NR==2)
$CYAN Features: $WHITE $features
$UNDERLINE$RED Vulnerabilities:$RESET$BOLD
$WHITE$vulnerabilities"
}
#default state of getting cpu load
cpu_load_without_adb() {
local cpu_usage=$(ps aux | awk 'BEGIN {sum=0} {sum+=$3}; END {printf "%.2f%%\n",sum}')
PRINT $BOLD"
$CYAN CPU Load(within Termux): $WHITE $cpu_usage"
}
#Function to read CPU stats from /proc/stat
read_cpu_stats() {
read cpu user nice system idle iowait irq softirq steal guest guest_nice <<< $(run-shell grep '^cpu ' /proc/stat)
}
#get CPU frequency
read_cpu_mhz() {
local core_number=-1
local cores=()
local freqs=()
#loop through each CPU core.
for file in /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq; do
#get CPU core number.
((core_number++))
#store it in array.
cores+=("$core_number")
#extract frequency values in KHz.
freq_khz=$(cat "$file")
# Convert kHz to MHz
freq_mhz=$(echo "scale=2; $freq_khz / 1000" | bc)
freqs+=("$freq_mhz")
done
for ((i=0; i<${#cores[@]}; i++)); do
PRINT $BOLD"
$CYAN CPU core ${cores[i]}:$WHITE ${freqs[i]} MHz"
done
}
#Function to calculate CPU usage percentage
calculate_cpu_usage() {
local prev_idle=$1
local prev_total=$2
local idle=$3
local total=$4
local idle_delta=$((idle - prev_idle))
local total_delta=$((total - prev_total))
# Avoid division by zero
if [[ $total_delta -eq 0 ]]; then
echo "0.00"
return
fi
local cpu_usage=$(bc -l <<< "scale=2; (1 - ($idle_delta /$total_delta)) * 100")
echo $cpu_usage
}
# Initial readings
read_cpu_stats
prev_idle=$idle
prev_total=$((user + nice + system + idle + iowait + irq + softirq + steal))
#fetch cpu load by adb
cpu_load_with_adb() {
read_cpu_stats
local cpu_usage=$(calculate_cpu_usage $prev_idle $prev_total $idle $((user + nice + system + idle + iowait + irq + softirq + steal)))
# Update previous values
prev_idle=$idle
prev_total=$((user + nice + system + idle + iowait + irq + softirq + steal))
PRINT $BOLD"
$CYAN Overall System Load:$WHITE $cpu_usage%"
}
#check status to run function by adb or without adb
check_status() {
if check_adb_port; then
connect_adb
cpu_load_with_adb
else
PRINT $BOLD"
$YELLOW$BOLD INFO:$RESET Fetching CPU load via 'ps'"
cpu_load_without_adb
fi
}
PRINT $BOLD"
$UNDERLINE$MAGENTA CPU Details:$RESET"
cpu_info
PRINT $BOLD"
$UNDERLINE$MAGENTA CPU Load:$RESET"
check_status
PRINT "
$YELLOW$BOLD INFO:$RESET Press 'l' for Live Monitoring...
$YELLOW$BOLD INFO:$RESET Press 'Enter' or any key to Quit."
read -n 1 key
if [[ $key = "l" ]]; then
clear
while true; do
tput cup 0
tput el
PRINT $BOLD"
$UNDERLINE$MAGENTA CPU Load Live Monitoring:$RESET"
PRINT $BOLD"
$CYAN Model name: $WHITE $(echo "$model_names" | awk NR==1)
$CYAN Min MHz: $WHITE $(echo "$min_max_values" | awk NR==2) $(echo "$min_max_values" | awk NR==4)
$CYAN Max MHz: $WHITE $(echo "$min_max_values" | awk NR==1) $(echo "$min_max_values" | awk NR==3)"
PRINT $BOLD"
$UNDERLINE$MAGENTA CPU Cores:$RESET"
read_cpu_mhz
PRINT $BOLD"
$UNDERLINE$MAGENTA CPU Load:$RESET"
check_status
PRINT "
$YELLOW$BOLD INFO:$RESET Press 'Enter' or any key to Quit."
sleep 1
read -n 1 -s -t 1 && break
done
fi
}
#Disk Usage
disk() {
clear
PRINT $BOLD"
$UNDERLINE$MAGENTA Disk Usage:$RESET"
duf -only-fs sdcardfs
PRINT "
$YELLOW$BOLD INFO:$RESET Press 'm' to get all disk usage...
$YELLOW$BOLD INFO:$RESET Press 'Enter' or any key to Quit."
read -n 1 key
if [[ $key = "m" ]]; then
clear
PRINT $BOLD"
$UNDERLINE$MAGENTA Disk Usage(all):$RESET"
duf
PRINT "
$YELLOW$BOLD INFO:$RESET Press 'Enter' or any key to Quit."
read -n 1 && break
fi
}
#info about android software
androidinfo() {
clear
PRINT $BOLD"
$UNDERLINE$MAGENTA Android Software Info:$RESET$BOLD
$CYAN Brand: $WHITE $(getprop ro.product.brand)
$CYAN Manufacturer: $WHITE $(getprop ro.product.manufacturer)
$CYAN Device Model: $WHITE $(getprop ro.product.model)
$CYAN Device UI: $WHITE $(getprop ro.product.brand.ui)
$CYAN Android Version: $WHITE $(getprop ro.build.version.release)
$CYAN SDK Version: $WHITE $(getprop ro.build.version.sdk)
$CYAN Build Number: $WHITE $(getprop ro.build.display.id)
$CYAN Build Date: $WHITE $(date -d @$(getprop ro.build.date.utc))
$CYAN Baseband: $WHITE $(getprop gsm.version.baseband)
$CYAN Build Type: $WHITE $(getprop ro.build.type)
$CYAN Build ID: $WHITE $(getprop ro.product.build.id)
$CYAN Language: $WHITE $(getprop persist.sys.locale)
$CYAN Timezone: $WHITE $(getprop persist.sys.timezone)"
PRINT "$BOLD
$YELLOW INFO:$RESET Press 'Enter' or any key to Quit..."
read -r
}
#wifi info
wifi_info() {
termux_api_with_prompt_setup
local data=$(termux-wifi-connectioninfo)
local status=$(jq -r '.supplicant_state' <<< "$data")
local name=$(jq -r '.ssid' <<< "$data")
local hidden_state=$(jq -r '.ssid_hidden' <<< "$data")
local freq=$(jq -r '.frequency_mhz' <<< "$data")
local ip=$(jq -r '.ip' <<< "$data")
local mac_address=$(jq -r '.mac_address' <<< "$data")
local max_speed=$(jq -r '.link_speed_mbps' <<< "$data")
if [[ $status != "COMPLETED" ]]; then
PRINT $YELLOW "WiFi information not available."
return 1
fi
hidden_state=$( [[ "$hidden_state" == "true" ]] && echo "Yes" || echo "No" )
PRINT $BOLD"
$UNDERLINE $MAGENTA WiFi Info:$RESET$BOLD
$CYAN WiFi Name: $WHITE $name
$CYAN Hidden State: $WHITE $hidden_state
$CYAN Frequency: $WHITE $freq MHz
$CYAN IP Address: $WHITE $ip
$CYAN MAC Address: $WHITE $mac_address
$CYAN Max Speed: $WHITE $max_speed mbps"
}
#cellular info
cellular_info() {
termux_api_with_prompt_setup
local data=$(termux-telephony-deviceinfo)
local network=$(jq -r '.network_operator_name' <<< "$data")
local type=$(jq -r '.network_type' <<< "$data")
local roaming=$(jq -r '.network_roaming' <<< "$data")
local data_enabled=$(jq -r '.data_enabled' <<< "$data")
local connection=$(jq -r '.data_state' <<< "$data")
local signal=$(jq -r '.signal_strength' <<< "$data")
local sim=$(jq -r '.sim_operator_name' <<< "$data")
local country=$(jq -r '.sim_country_iso' <<< "$data")
local state=$(jq -r '.sim_state' <<< "$data")
local dualsim=$(jq -r '.phone_count' <<< "$data")
local phone=$(jq -r '.phone_type' <<< "$data")
if [[ $state == "absent" ]]; then
echo "Cellular Network Info Not Available.."
return 1
fi
dualsim=$( [[ $dualsim -eq 2 ]] && echo "Yes" || echo "No" )
roaming=$( [[ $roaming == "true" ]] && echo "Enabled" || echo "Disabled" )
data_enabled=$( [[ $data_enabled == "true" ]] && echo "Enabled" || echo "Disabled" )
PRINT $BOLD"
$UNDERLINE$MAGENTA Cellular Info:$RESET$BOLD
$CYAN Network Operator: $WHITE $network
$CYAN Network Type: $WHITE $type
$CYAN Roaming: $WHITE $roaming
$CYAN Data Enabled: $WHITE $data_enabled
$CYAN Data Connection: $WHITE $connection
$CYAN Signal Strength: $WHITE $signal
$CYAN SIM Operator: $WHITE $sim
$CYAN SIM Country ISO: $WHITE $country
$CYAN SIM State: $WHITE $state
$CYAN Dual SIM Support: $WHITE $dualsim
$CYAN Phone Network Type: $WHITE $phone"
}
#Network Information
netstats () {
clear
HOST_NAME=$(hostname)
EXTERNALIP=$(curl -4 ifconfig.me 2>/dev/null)
INTERNALIP=$(hostname -i)
local STATUS=$(
if ping -q -c2 google.com &>/dev/null; then
PRINT $BOLD $GREEN "You are Up :)"
else
PRINT $BOLD $RED "You are Down :("
fi)
PRINT $BOLD"
$UNDERLINE$MAGENTA Network Basic Info:$RESET$BOLD
$CYAN Host Name: $WHITE $HOST_NAME
$CYAN External IP: $WHITE $EXTERNALIP
$CYAN Internal IP: $WHITE $INTERNALIP
$CYAN Connection Status: $WHITE $STATUS"
if check_termux_api; then
PRINT "$BOLD
$RED INFO:$RESET Some of data hidden, Please install termux-api to view properly...
$YELLOW INFO:$RESET Press 'Enter' or any key to Quit..."
read -r
else
wifi_info
cellular_info
fi
}
#System Base Information like kernel uptime
sysbaseinfo() {
clear
kn=$(uname -s)
kv=$(uname -v)
kr=$(uname -r)
ka=$(uname -m)
ko=$(uname -o)
uptime=$(uptime -p)
suptime=$(uptime -s)
PRINT $BOLD"
$UNDERLINE$MAGENTA Android Base Info:$RESET$BOLD
$CYAN Operating System: $WHITE $ko
$CYAN Kernel Name: $WHITE $kn
$CYAN Kernel Version: $WHITE $kr
$CYAN Kernel Release: $WHITE $kv
$CYAN System Architect: $WHITE $ka
$CYAN System Uptime: $WHITE $uptime
$CYAN System Since Boot: $WHITE $suptime"
PRINT "$BOLD
$YELLOW INFO:$RESET Press 'Enter' or any key to Quit..."
read -r
}
#Network Speed Checker
network_speed() {
clear
PRINT "
$UNDERLINE$YELLOW Running SpeedTest, Please Wait..."
tmpfile=$(mktemp)
speedtest-go | grep -E "Download|Upload|Latency" > "$tmpfile" & 2>/dev/null
local pid=$!
spinner "Fetching innternet speed..." $pid
wait $pid
download=$(grep -oP "Download:\s+\K[0-9.]+" "$tmpfile")
upload=$(grep -oP "Upload:\s+\K[0-9.]+" "$tmpfile")
latency=$(grep -oP "Latency:\s+\K[0-9.]+" "$tmpfile")
PRINT $BOLD"
$UNDERLINE$MAGENTA Internet Speed Data:$RESET$BOLD
$CYAN Download speed: $WHITE $download Mbps
$CYAN Upload speed: $WHITE $upload Mbps
$CYAN Latency: $WHITE $latency ms"
rm "$tmpfile"
PRINT "$BOLD
$YELLOW INFO:$RESET Press 'Enter' or any key to Quit..."
read -r
}
# battery function
battery() {
clear
termux_api_with_prompt_setup
get_batt_info() {
local data=$(termux-battery-status)
health=$(jq -r '.health' <<< "$data")
percentage=$(jq -r '.percentage' <<< "$data")
plugged=$(jq -r '.plugged' <<< "$data")
charging=$(jq -r '.status' <<< "$data")
temp=$(jq -r '.temperature' <<< "$data")
current=$(jq -r '.current' <<< "$data")
}
print_batt_details() {
PRINT $BOLD"
$CYAN Percentage: $WHITE $percentage%
$CYAN Health: $WHITE $health
$CYAN Current: $WHITE $current
$CYAN Temperature: $WHITE $temp
$CYAN Plugged: $WHITE $plugged
$CYAN Charging: $WHITE $charging"
}
get_batt_info
PRINT $BOLD"
$UNDERLINE$MAGENTA Battery Statistics:$RESET"
print_batt_details
PRINT "
$YELLOW$BOLD INFO:$RESET Press 'l' for Live Monitoring...
$YELLOW$BOLD INFO:$RESET Press 'Enter' or any key to Quit."
read -n 1 key
if [[ $key == "l" ]]; then
clear
while true; do
tput cup 0
tput el
get_batt_info
PRINT $BOLD"
$UNDERLINE$MAGENTA Battery Live Monitoring:$RESET"
print_batt_details
PRINT "
$YELLOW$BOLD INFO:$RESET Press 'Enter' or any key to Quit."
read -n 1 -s -t 1 && break
done
fi
}
# Sensors Info function
get_sensor_info() {
clear
termux_api_with_prompt_setup
local data=$(termux-sensor -l)
local SENSORS=$(jq -r '.sensors[]' <<< "$data")
PRINT $BOLD"
$UNDERLINE$MAGENTA Sensors List:$RESET
$WHITE$SENSORS
$YELLOW$BOLD INFO:$RESET Press 'Enter' or any key to Quit."
read -r
}
# Version
version() {
PRINT $BOLD"Android System Information
$WHITE Version: 2.1.0"
}
#Help Function
_help() {
PRINT $WHITE"$BOLD
Usage:$RESET <commands>.
A tool for displaying Android System Information
$BOLD
Flags:$RESET
-h, --help Show this help.
-v, --version Print the version number
$BOLD
Commands:$RESET
android Display Android System Overview.
disk Show disk usage.
cpu View CPU Information.
memory Display memory usage.
sysbinfo Provide system information.
netstats Show network statistics.
speed Measure internet Speed.
battery Display battery statistics.
sensor Get device sensors list.
$BOLD
Example:$RESET
sysinfo disk
"
}
netstat_help() {
PRINT $WHITE"$BOLD
Usage:$RESET sysinfo netstats [<options> ].
$BOLD
Flags:$RESET
--wifi - Show Wi-Fi connection Information if available.
--cellular - Show cellular connection Information if available.
--help - Shows this Help.
$BOLD
Example:$RESET
sysinfo netstats --wifi
"
}
#check adb status
ADB_STATUS=$(
if check_adb_port; then
PRINT "$BOLD$GREEN CONNECTED $RESET"
else
PRINT "$BOLD$RED DIS-CONNECTED $RESET"
fi)
#check termux-api status
TERMUX_API_STATUS=$(
if check_termux_api; then
PRINT "$BOLD$RED NOT-INSTALLED"
else
PRINT "$BOLD$GREEN INSTALLED"
fi)
#check script update status
UPDATE_STATUS=$(
if monitor_update; then
PRINT "$BOLD$GREEN AVAILABLE"
else
PRINT "$BOLD$BLUE UP-TO-DATE"
fi)
# Display menu function
display_menu() {
PRINT "
$BOLD$BLUE $(figlet -c -t -f term "SYSTEM INFORMATION v2.0")
$BOLD$YELLOW $(figlet -c -t -f term "Github: https://github.com/Aj-Seven/Android-Sysinfo")
$BOLD$CYAN $(figlet -c -t -f digital "Author: @Aj-Seven")
$BOLD$MAGENTA UPDATES:$RESET$UPDATE_STATUS | $BOLD$MAGENTA ADB:$RESET$ADB_STATUS
$BOLD$MAGENTA TERMUX-API:$RESET$TERMUX_API_STATUS
$UNDERLINE Select the options below:$RESET$BOLD$WHITE
01) Android Info
02) Disk Fetch
03) CPU Info
04) Memory Fetch
05) System BaseInfo
06) Network Stats
07) Internet Speed
08) Battery Stats
09) Sensor Info
10) Check Updates
00) Quit\n"
}
main() {
clear
display_menu
read opt
case $opt in
1) androidinfo ;;
2) disk ;;
3) cpu ;;
4) memusage ;;
5) sysbaseinfo ;;
6) netstats ;;
7) network_speed ;;
8) battery;;
9) get_sensor_info;;
10) check_update ;;
0) PRINT $RED "Exiting...:)"
sleep 0.5s;
exit 0;
;;
*)
PRINT $CYAN "Error Selection. Try Again..."
;;
esac
}
# Set the default PREFIX if not provided
if [ -z "$PREFIX" ]; then
PREFIX="/data/data/com.termux/files/usr/"
fi
if [ $# -eq 0 ]; then
command clear
while true; do
main
done
fi
while [[ "$#" -gt 0 ]]; do
case $1 in
-v|--version) version;;
android) androidinfo;;
disk) disk;;
cpu) cpu;;
memory) memusage;;
sysbinfo) sysbaseinfo;;
netstats)
case "$2$3" in
"--wifi--cellular" | "--cellular--wifi")
wifi_info
cellular_info
;;
"--wifi")
wifi_info
;;
"--cellular")
cellular_info
;;
"--help")
netstat_help
;;
*)
if [ -z "$2" ] && [ -z "$3" ]; then
netstats
else
netstat_help
PRINT $RED $BOLD"Error:$RESET Unknown Option '$2$3'"
fi
esac
break
;;
speed) network_speed;;
battery) battery;;
sensor) get_sensor_info;;
-h|--help) _help ;;
*) _help
PRINT $RED $BOLD"Error:$RESET Unknown Option '$1'"
exit 1;;
esac
shift
done