-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtel-fetch
More file actions
executable file
·101 lines (89 loc) · 4.77 KB
/
Copy pathtel-fetch
File metadata and controls
executable file
·101 lines (89 loc) · 4.77 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
#!/usr/bin/env bash
if [ -d /system/app ] && [ -d /system/priv-app ]; then #check if running on android
#x=1
#if [ $x == 1 ]; then #check if running on android
# shellcheck disable=SC2086,SC2048
trim_all() {
# remove whitespace from string
# Usage: trim_all " example string "
set -f
set -- $*
printf '%s\n' "$*"
set +f
}
reverse() {
# flip an array - first index becomes last and so forth
# first argument is the array to reverse
# second is the output array
declare -n arr="$1" rev="$2"
for i in "${arr[@]}"
do
rev=("$i" "${rev[@]}")
done
}
# get kernal, os and arch
read -r os kernel arch <<-EOF
$(uname -srm)
EOF
# root detection
rooted= ; su -c echo > /dev/null 2>&1 && {
rooted="/root"
}
# time_zone="$(getprop persist.sys.timezone)"
android_version="$(getprop ro.build.version.release)"
device_model="$(getprop ro.product.name)"
device_rom="$(getprop ro.vendor.build.id)"
security_patch="$(getprop ro.build.version.security_patch)"
######## CPU #######
speed_dir="/sys/devices/system/cpu/cpu0/cpufreq"
cpu_file="/proc/cpuinfo"
IFS=' ' read -a cpu_info <<-EOF #read into array
$(awk -F '\\s*: | @' \
'/model name|Hardware|Processor|^cpu model|chip type|^cpu type/ {
cpu=$2; if ($1 == "Hardware") exit } END { print cpu }' "$cpu_file")
EOF
reverse cpu_info cpu_info_rev # flip to get cpu model
cpu="${cpu_info_rev[0]}" # first becomes model
# maxspeed="$(< "${speed_dir}/cpuinfo_max_freq")"
# maxspeed="$((maxspeed / 1000)) MHz"
speed="$(< "${speed_dir}/scaling_max_freq")" ||\
speed="$(< "${speed_dir}/cpuinfo_max_freq")"
speed="$((speed / 1000))MHz"
cores=$(cat /proc/cpuinfo | grep -e 'CPU architecture' | tail -n 1 | cut -d' ' -f3)
###############################
####### MEMORY ##########
memtotal="$(cat /proc/meminfo | grep -e 'MemTotal' | cut -d' ' -f9)"
memtotal="$(( memtotal / 1000 )) MiB"
memfree="$(trim_all "$(cat /proc/meminfo | grep -e 'MemAvailable' | cut -d':' -f2| cut -d'k' -f1)")"
memfree="$(( memfree / 1000 ))"
##########################
########### UPTIME #######
uptime=$(uptime | awk -F'( |,|:)+' '{d=h=m=0; if ($7=="min") m=$6; else {if ($7~/^day/) {d=$6;h=$8;m=$9} else {h=$6;m=$7}}} {print d+0,"days,",h+0,"hrs,",m+0,"mins"}')
#truncate strings here
#length of tellogo line = ?? 43 roughly
#max width of text with the logo =
max_width=$((COLUMNS - 43))
uptime=${uptime:0:$max_width}
##### ADD COLORS
echo -ne """
\e[1;31m▒\e[0m°.
\e[1;31m▒▒▒\e[0mo
\e[1;31m▒▒▒▒▒▒▒▒▒ ▒▒▒\e[0mo
\e[1;31m▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒\e[0mO
\e[1;31m▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒\e[0m0 \e[3m\e[1m ${NAME}${rooted}@${device_model} $time_zone \e[0m
\e[1;31m▒▒▒ ▒▒▒▒▒\e[0m^\e[1;31m▒▒▒\e[0m^\e[1;31m▒▒▒ ▒▒▒▒\e[0m0\e[1;31m▒▒▒▒\e[0m \e[9m \e[m
▄▄\e[1;31m▒▒▒▒▒\e[0m▄▄▄▄▄\e[1;31m▒▒▒▒▒▒▒▒▒\e[0m▄▄\e[1;31m▒▒▒▒▒▒▒▒▒▒▒▒\e[0m \e[1m os:\e[0m Android $android_version $arch
▌ \e[1;31m▒▒▒\e[0m ▌ \e[1;31m▒▒▒▒\e[0m ▌\e[1;31m▒▒\e[0m \e[1m build:\e[0m $device_rom
▌▄▄▄\e[1;31m▒▒\e[0m .;\e[1;31m▒\e[0m▄▄▄▄▌ ▄▄▄▄▄▄o\e[1;31m▒▒▒▒\e[0m ▌\e[1;31m▒▒\e[0m \e[1m patch:\e[0m $security_patch
\e[1;31m▒▒\e[0m▌\e[1;31m▒▒▒▒\e[0m ▌\e[1;31m▒▒▒\e[0m▌ ▌▄▄▄▄▄o\e[1;31m▒▒▒▒\e[0m ▌0\e[1;31m▒▒\e[0m \e[1m kern:\e[0m $kernel
\e[1;31m▒▒▒\e[0m▌ ▌\e[1;31m▒▒\e[0m0▌ o\e[1;31m▒▒▒\e[0m ▌O\e[1;31m▒▒\e[0m \e[1m cpu:\e[0m $cpu ($cores) @ $speed
\e[1;31m▒▒▒\e[0m0▌ ▌\e[1;31m▒▒\e[0mO▌ ▄▄▄▄o\e[1;31m▒▒▒▒\e[0m . ▌o\e[1;31m▒▒\e[0m \e[1m mem:\e[0m $memfree / $memtotal available
\e[1;31m▒▒▒\e[0mO▌ ∙ °\e[1;31m▒\e[0m▌ \e[1;31m▒▒\e[0mO ▌▄▄▄\e[1;31m▒▒▒\e[0m▌ \e[1;31m▒\e[0mo\e[1;31m▒▒▒\e[0m▄▄▄ \e[1m up:\e[0m $uptime
\e[1;31m▒▒▒\e[0mo\e[1;31m▒▒▒▒▒\e[0m▌ \e[1;31m▒▒\e[0mo O\e[1;31m▒▒\e[0m ▌ \e[1;31m▒▒\e[0m ▌
\e[1;31m▒▒▒\e[0m▄▄▄▄▌ \e[1;31m▒▒\e[0mo▄▄▄▄▄▄\e[1;31m▒▒▒\e[0m▌▄▄▄▄▄▄▄▄▄▄▄▄▌
\e[1;31m▒▒\e[0mo o\e[1;31m▒▒\e[0m o\e[1;31m▒▒\e[0m
\e[1;31m▒\e[0mo °\e[1;31m▒\e[0m
"""
else
echo 'Only made for android'
fi