-
Notifications
You must be signed in to change notification settings - Fork 1
/
device_info.txt
executable file
·226 lines (187 loc) · 5.93 KB
/
device_info.txt
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
#!/bin/bash
## New Device Info
#
# - DISPLAY_WIDTH
# - DISPLAY_HEIGHT
# - DISPLAY_ORIENTATION
# - CFW_NAME
# - CFW_VERSION
# - DEVICE_NAME
# - DEVICE_CPU
# - DEVICE_RAM
# - DEVICE_ARCH
# - ANALOG_STICKS
#
# usage `source <path_to>/device_info.txt`
DEVICE_INFO_VERSION="0.1.3"
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
CFW_NAME="Unknown"
CFW_VERSION="Unknown"
if [ -f "/usr/share/plymouth/themes/text.plymouth" ]; then
CFW_INFO=$(grep "title=" "/usr/share/plymouth/themes/text.plymouth")
CFW_FFS=$(grep -a "title=" "/usr/share/plymouth/themes/text.plymouth" | cut -d'=' -f 2- | tr -cd 'a-zA-Z' | tr '[:upper:]' '[:lower:]')
if [[ $CFW_FFS == *"thera"* ]]; then
CFW_NAME="TheRA"
CFW_VERSION="Unknown"
elif [[ $CFW_FFS == *"retrooz"* ]]; then
CFW_NAME="RetroOZ"
CFW_VERSION="Unknown"
elif [[ $CFW_FFS == *"arkos"* ]]; then
CFW_NAME=$(echo "${CFW_INFO}" | sed -n 's/title=\(.*\) (\([0-9]\{8\}\))/\1/p' | cut -d' ' -f 1)
CFW_VERSION=$(echo "${CFW_INFO}" | sed -n 's/title=\(.*\) (\([0-9]\{8\}\))/\2/p' | cut -d' ' -f 1)
if [[ $CFW_FFS == *"wummle"* ]]; then
CFW_NAME="${CFW_NAME} wuMMLe"
fi
fi
unset CFW_INFO
unset CFW_FFS
elif [ -f "/opt/muos/config/version.txt" ]; then
# muOS - RG35XX Plus/H
CFW_NAME="muOS"
CFW_VERSION=$(head -n1 "/opt/muos/config/version.txt")
else
# AmberELEC / EmuELEC
CFW_NAME=$(grep -a '^NAME=".*"' /etc/os-release | cut -d'"' -f 2)
CFW_VERSION=$(grep -a '^VERSION=".*"' /etc/os-release | cut -d'"' -f 2)
if [ -z "$CFW_NAME" ]; then
# uOS / JELOS
CFW_NAME=$(grep -a '^OS_NAME=".*"' /etc/os-release | cut -d'"' -f 2)
CFW_VERSION=$(grep -a '^OS_VERSION=".*"' /etc/os-release | cut -d'"' -f 2)
fi
fi
DEVICE_RAM=$(free | awk '/Mem:/ { printf("%.0f", ($2 / 1024 / 1024)) }')
# Get DEVICE_NAME
if [[ "$CFW_NAME" == "EmuELEC" ]]; then
DEVICE_NAME=$(grep -a '^COREELEC_DEVICE=".*"' /etc/os-release | cut -d'"' -f 2)
elif [ -f "~/.config/.CUSTOM_DEVICE" ]; then
DEVICE_NAME=$(cat "~/.config/.CUSTOM_DEVICE")
elif [ -f "~/.config/.DEVICE" ]; then
DEVICE_NAME=$(cat "~/.config/.DEVICE")
elif [ -f "~/.config/.OS_ARCH" ]; then
DEVICE_NAME=$(cat "~/.config/.OS_ARCH")
elif [ -f "/sys/firmware/devicetree/base/model" ]; then
DEVICE_NAME=$(cat "/sys/firmware/devicetree/base/model" | cut -d' ' -f 2)
if [[ "${DEVICE_NAME}" == "" ]]; then
DEVICE_NAME=$(cat "/sys/firmware/devicetree/base/model" 2>/dev/null)
fi
else
DEVICE_NAME="Unknown"
fi
ANALOG_STICKS=2
DEVICE_CPU="Unknown"
DEVICE_ARCH=$(uname -m)
DISPLAY_ORIENTATION=0
## FIXES
# Here is where we can add custome rules to fill out extra info on the device.
case "$(echo ${DEVICE_NAME} | tr '[:upper:]' '[:lower:]')" in
# by cpu
"rk3399")
DEVICE_NAME="RG552"
DEVICE_CPU="RK3399"
;;
"rk3566")
DEVICE_CPU="RK3566"
if [[ "${DISPLAY_WIDTH}x${DISPLAY_HEIGHT}" == "960x544" ]]; then
# Nice
DEVICE_NAME="RG503"
elif [[ "${DISPLAY_WIDTH}x${DISPLAY_HEIGHT}" == "1280x720" ]]; then
# and
DEVICE_NAME="x55"
elif [[ "${DISPLAY_WIDTH}x${DISPLAY_HEIGHT}" == "720x720" ]]; then
# easy
DEVICE_NAME="RGB30"
else
# fuck it, close enough
if [[ "$DEVICE_RAM" == "2" ]]; then
DEVICE_NAME="RG353M"
else
DEVICE_NAME="RG353VS"
fi
fi
;;
"rk3326")
DEVICE_CPU="RK3326"
if [[ "${DISPLAY_WIDTH}x${DISPLAY_HEIGHT}" == "854x480" ]]; then
# Could be this, i guess...
DEVICE_NAME="ODROID-GO Super"
elif [[ "${DISPLAY_WIDTH}x${DISPLAY_HEIGHT}" == "640x480" ]]; then
# or could be this...
DEVICE_NAME="RG351MP"
else
# fuck it, close enough
DEVICE_NAME="RG351P"
fi
;;
# by actual device
"rg353v"|"rg353p"|"rg353vs"|"rg353ps"|"rg353m")
DEVICE_CPU="RK3566"
;;
"rg351mp"|"rg351p")
DEVICE_CPU="RK3326"
;;
"x55")
DEVICE_CPU="RK3566"
;;
"rg351v")
ANALOG_STICKS=1
DEVICE_CPU="RK3326"
;;
"rg552")
DEVICE_CPU="RK3399"
;;
"gameforce")
DEVICE_CPU="RK3326"
;;
"ace")
DEVICE_CPU="RK3388"
;;
"amlogic-ng")
DEVICE_NAME=$(cat "/sys/firmware/devicetree/base/model" 2> /dev/null | cut -d' ' -f 2)
DEVICE_CPU="S922X"
;;
"super")
DEVICE_NAME="ODROID-GO Super"
DEVICE_CPU="RK3326"
;;
"odroid-go super")
DEVICE_CPU="RK3326"
;;
"sun50iw9")
if [ -f "/opt/muos/config/device.txt" ]; then
if [ "$(cat /opt/muos/config/device.txt)" == "RG35XX-PLUS" ]; then
ANALOG_STICKS=0
DEVICE_NAME="RG35XX PLUS"
else
DEVICE_NAME="RG35XX H"
fi
else
DEVICE_NAME="RG35XX H"
fi
DEVICE_CPU="H700"
DEVICE_ARCH="armhf"
;;
esac
# get current resolution
IFS='x' read -r DISPLAY_WIDTH DISPLAY_HEIGHT < <($SCRIPT_DIR/sdl_resolution.$DEVICE_ARCH 2> /dev/null | grep -a 'Current' | awk -F ': ' '{print $2}')
unset SCRIPT_DIR
# Check if the values are not empty, otherwise, set default resolution
if [ -z "$DISPLAY_WIDTH" ] || [ -z "$DISPLAY_HEIGHT" ]; then
DISPLAY_WIDTH=640
DISPLAY_HEIGHT=480
fi
cat << __INFO_DUMP__ | tee "device_info_${CFW_NAME}_${DEVICE_NAME}.txt"
# ${DEVICE_NAME} - ${CFW_NAME}
\`\`\`bash
DEVICE_INFO_VERSION=${DEVICE_INFO_VERSION}
CFW_NAME=${CFW_NAME}
CFW_VERSION=${CFW_VERSION}
DEVICE_NAME=${DEVICE_NAME}
DEVICE_CPU=${DEVICE_CPU}
DEVICE_ARCH=${DEVICE_ARCH}
DEVICE_RAM=${DEVICE_RAM}
DISPLAY_WIDTH=${DISPLAY_WIDTH}
DISPLAY_HEIGHT=${DISPLAY_HEIGHT}
DISPLAY_ORIENTATION=${DISPLAY_ORIENTATION}
ANALOG_STICKS=${ANALOG_STICKS}
\`\`\`
__INFO_DUMP__