forked from farkmarnum/webos-custom-home-screen
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwebos_custom_home_screen
More file actions
executable file
·249 lines (215 loc) · 10 KB
/
webos_custom_home_screen
File metadata and controls
executable file
·249 lines (215 loc) · 10 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
#!/bin/bash
# WebOS Custom Home Screen
# WARNING! This script is provided with no warranty, use at your own risk.
set -e
############ Begin User Customizable ENV Variables
# Set WEBOS_CUSTOM_HOME_SCREEN_ENABLED=false to disable this script.
WEBOS_CUSTOM_HOME_SCREEN_ENABLED=true
TOP_SHELF_ENABLED=true
AI_BOARD_ENABLED=true
RECOMMENDED_ENABLED=true
############ END User Customizable ENV Variables. Advanced users only past this point.
# This is the directory we will mount override files from.
WORKDIR="/tmp/webos_custom_home_screen"
# These are the source files that we will copy and modify.
AI_BOARD_SOURCE="/usr/palm/applications/com.webos.app.home/qml/UserInterfaceLayer/Containers/Main/AIBoard.qml"
RECOMMENDED_SOURCE="/usr/palm/applications/com.webos.app.home/qml/UserInterfaceLayer/Containers/Main/Recommended.qml"
TOP_SHELF_SOURCE="/usr/palm/applications/com.webos.app.home/qml/UserInterfaceLayer/Containers/Main/TopShelf.qml"
APP_INTERFACES_SOURCE="/usr/palm/applications/com.webos.app.home/qml/Interfaces/AppInterfaces/AppInterfaces.qml"
check_war_enabled() {
# This can be used to disable the script while keeping it in place. Set WEBOS_CUSTOM_HOME_SCREEN_ENABLED to false in the env variables above.
if [ $WEBOS_CUSTOM_HOME_SCREEN_ENABLED = false ]; then
echo "WEBOS_CUSTOM_HOME_SCREEN_ENABLED set to false, exiting."
rm -fr $WORKDIR
exit 1
fi
}
check_install() {
# Check if installed. If not do install. If installed run from install location to ensure applying user settings
if [ ! -f "/var/lib/webosbrew/init.d/webos_custom_home_screen" ]; then
echo "Script is not installed. Installing."
curl -s -L https://raw.githubusercontent.com/farkmarnum/webos-custom-home-screen/main/webos_custom_home_screen > /var/lib/webosbrew/init.d/webos_custom_home_screen
chmod +x /var/lib/webosbrew/init.d/webos_custom_home_screen
else
script_name1=`basename $0`
script_path1=`dirname $0`
script_path_with_name="$script_path1/$script_name1"
if [ "$script_path_with_name" = "/var/lib/webosbrew/init.d/webos_custom_home_screen" ]; then
echo "Script installed and started from right location, executing."
else
echo "Runnning Script from right location."
(/var/lib/webosbrew/init.d/webos_custom_home_screen)
exit 1
fi
fi
}
check_target_sums() {
# We check sha512 sum of target files before proceeding. We will be inserting a line of code at a specific line, we do this to ensure
# there are no unexpected results. Old versions of WebOS or updates may cause files to change, which will break this script.
case $1 in
"ai_board")
AI_BOARD_SUM="4cff08f7438bc55fe6f5010aebc4132c3da3a083dbf8baa7490c15a18a79be15b122516b579a5b0c2fcaa6359b712f3bf664975e87cfffec66efc9667fe14e5e /usr/palm/applications/com.webos.app.home/qml/UserInterfaceLayer/Containers/Main/AIBoard.qml"
AI_BOARD_CHECK=$(sha512sum $AI_BOARD_SOURCE)
if [ "$AI_BOARD_SUM" != "$AI_BOARD_CHECK" ]; then
echo "Shasum did not match for AIBoard.qml! Script will not proceed!"
exit 1
fi
echo "Checksum matched!"
;;
"recommended")
RECOMMENDED_SUM="ba877634207a03d2e58868f452b84b5f91985763463fd6d1db506f2d80cc4a9fd0c91e564976df9df04fc5dcc1ff5e36b3c8ff7d2213f747e321d00ae1511d62 /usr/palm/applications/com.webos.app.home/qml/UserInterfaceLayer/Containers/Main/Recommended.qml"
RECOMMENDED_CHECK=$(sha512sum $RECOMMENDED_SOURCE)
if [ "$RECOMMENDED_SUM" != "$RECOMMENDED_CHECK" ]; then
echo "Shasum did not match for Recommended.qml! Script will not proceed!"
exit 1
fi
echo "Checksum matched!"
;;
"top_shelf")
TOP_SHELF_SUM="d142a5625a63dd5913afe02c4e216a7b48106025db7b34d89db641a19b7b7e0170a66956c5400af3cc0aa35816a62cad1ce4d8fac8b33f01d49b2652a1461904 /usr/palm/applications/com.webos.app.home/qml/UserInterfaceLayer/Containers/Main/TopShelf.qml"
TOP_SHELF_CHECK=$(sha512sum $TOP_SHELF_SOURCE)
if [ "$TOP_SHELF_SUM" != "$TOP_SHELF_CHECK" ]; then
echo "Shasum did not match for TopShelf.qml! Script will not proceed!"
exit 1
fi
echo "Checksum matched!"
;;
*)
echo "Attempted to check sum with unrecognized argument! Exiting."
exit 1
;;
esac
}
check_workdir() {
# Del workimg directory and recreate it every script run.
if [ ! -d "$WORKDIR" ]; then
mkdir -p $WORKDIR
fi
}
create_top_shelf_override() {
umount "$TOP_SHELF_SOURCE" > /dev/null 2>&1 || :
check_target_sums "top_shelf"
# This runs if the modified file is not found.
# Then we copy the AIBoard.qml file to our workdir.
cp $TOP_SHELF_SOURCE "$WORKDIR/TopShelf.qml"
# Finally we modify the file.
sed -i '17 i return' "$WORKDIR/TopShelf.qml"
}
remove_top_shelf() {
# First we check if the AIBoard.qml file exists on the USB. If it does not we create it.
if [ $TOP_SHELF_ENABLED = true ]; then
if [ ! -f "$WORKDIR/TopShelf.qml" ]; then
echo "TopShelf override file did not exist. Creating one now."
create_top_shelf_override
else
echo "TopShelf override file found at $WORKDIR/TopShelf.qml"
fi
# Then we mount --bind the TopShelf.qml override file. This is a non destructive action that can be reset with a reboot or umount.
mount --bind "$WORKDIR/TopShelf.qml" "$AI_BOARD_SOURCE"
else
echo "TopShelf block disabled. Reverting changes"
umount "$TOP_SHELF_SOURCE" > /dev/null 2>&1 || :
rm -fr $WORKDIR/TopShelf.qml
fi
}
create_app_interfaces_override() {
umount "$APP_INTERFACES_SOURCE" > /dev/null 2>&1 || :
# check_target_sums "app_interfaces"
# This runs if the modified file is not found.
# Then we copy the AIBoard.qml file to our workdir.
cp $APP_INTERFACES_SOURCE "$WORKDIR/AppInterfaces.qml"
# Finally we modify the file.
sed -i '312 i console.log("HERE", item)' "$WORKDIR/AppInterfaces.qml"
}
debug_app_interfaces() {
# First we check if the AIBoard.qml file exists on the USB. If it does not we create it.
if [ 1 = 1 ]; then
if [ ! -f "$WORKDIR/AppInterfaces.qml" ]; then
echo "AppInterfaces override file did not exist. Creating one now."
create_app_interfaces_override
else
echo "AppInterfaces override file found at $WORKDIR/AppInterfaces.qml"
fi
# Then we mount --bind the AppInterfaces.qml override file. This is a non destructive action that can be reset with a reboot or umount.
mount --bind "$WORKDIR/AppInterfaces.qml" "$APP_INTERFACES_SOURCE"
else
echo "AppInterfaces block disabled. Reverting changes"
umount "$APP_INTERFACES_SOURCE" > /dev/null 2>&1 || :
rm -fr $WORKDIR/AppInterfaces.qml
fi
}
create_ai_board_override() {
#! mountpoint -q "$AI_BOARD_SOURCE" || umount "$AI_BOARD_SOURCE"
umount "$AI_BOARD_SOURCE" > /dev/null 2>&1 || :
check_target_sums "ai_board"
# This runs if the modified file is not found.
# Then we copy the AIBoard.qml file to our workdir.
cp $AI_BOARD_SOURCE "$WORKDIR/AIBoard.qml"
# Finally we modify the file.
sed -i '17 i return' "$WORKDIR/AIBoard.qml"
}
remove_ai_board() {
# First we check if the AIBoard.qml file exists on the USB. If it does not we create it.
if [ $AI_BOARD_ENABLED = true ]; then
if [ ! -f "$WORKDIR/AIBoard.qml" ]; then
echo "AIBoard override file did not exist. Creating one now."
create_ai_board_override
else
echo "AIBoard override file found at $WORKDIR/AIBoard.qml"
fi
# Then we mount --bind the AIBoard.qml override file. This is a non destructive action that can be reset with a reboot or umount.
mount --bind "$WORKDIR/AIBoard.qml" "$AI_BOARD_SOURCE"
else
echo "AIBoard block disabled. Reverting changes"
#! mountpoint -q "$AI_BOARD_SOURCE" || umount "$AI_BOARD_SOURCE"
umount "$AI_BOARD_SOURCE" > /dev/null 2>&1 || :
rm -fr $WORKDIR/AIBoard.qml
fi
}
create_recommended_override() {
#! mountpoint -q "$RECOMMENDED_SOURCE" || umount "$RECOMMENDED_SOURCE"
umount "$RECOMMENDED_SOURCE" > /dev/null 2>&1 || :
check_target_sums "recommended"
# This runs if the modified file is not found.
# Then we copy the Recommended.qml file to our workdir.
cp $RECOMMENDED_SOURCE "$WORKDIR/Recommended.qml"
# Finally we modify the file.
sed -i '17 i return' "$WORKDIR/Recommended.qml"
}
remove_recommended() {
# First we check if the Recommended.qml file exists on the USB.
if [ $RECOMMENDED_ENABLED = true ]; then
if [ ! -f "$WORKDIR/Recommended.qml" ]; then
echo "Recommended override file did not exist. Creating one now."
create_recommended_override
else
echo "Recommended override file found at $WORKDIR/Recommended.qml"
fi
# Then we mount --bind the Recommended.qml override file. This is a non destructive action that can be reset with a reboot or umount.
mount --bind "$WORKDIR/Recommended.qml" "$RECOMMENDED_SOURCE"
else
echo "Recommended block disabled. Reverting changes"
#! mountpoint -q "$RECOMMENDED_SOURCE" || umount "$RECOMMENDED_SOURCE"
umount "$RECOMMENDED_SOURCE" > /dev/null 2>&1 || :
rm -fr $WORKDIR/Recommended.qml
fi
}
init() {
pkill -f com.webos.app.home
# Make sure WEBOS_CUSTOM_HOME_SCREEN_ENABLED is not set to false
check_war_enabled
# Check install
check_install
# This is the entrypoint for the script.
check_workdir
# Optional. This removes the AI Board (Top bar with 3 boxes. Includes ad, hero banner)
remove_ai_board
# Optional. This removes the trending section
remove_recommended
# Removes the whole top shelf container
remove_top_shelf
debug_app_interfaces
# When we are done we kill webOS home. This forces it to restart and use our changes.
pkill -f com.webos.app.home
}
init