8
8
echo " Please set \$ {WKDEV_SDK} to point to the root of the wkdev-sdk checkout."
9
9
exit 1
10
10
fi
11
+ if [[ -z ${WKDEV_SDK_HOST} ]]; then
12
+ echo " Please set \$ {WKDEV_SDK_HOST} to point to the the wkdev-sdk checkout (from the host perspective). This is used when creating .desktop entries."
13
+ exit 1
14
+ fi
15
+ if [[ ! -d /host/${HOME} ]]; then
16
+ echo " Host and container home must have the same path: /host/${HOME} "
17
+ exit 1
18
+ fi
11
19
source " ${WKDEV_SDK} /utilities/prerequisites.sh"
12
20
13
21
init_application " ${0} " " Configures Visual Studio Code." container-only
@@ -17,8 +25,10 @@ verify_executables_exist curl
17
25
argsparse_allow_no_argument true
18
26
argsparse_use_option " =yes" " Assume yes for all prompts."
19
27
argsparse_use_option " no-extensions" " Don't install extensions."
28
+ argsparse_use_option " no-proprietary" " Use VSCodium instead of VSCode."
20
29
21
30
install_vscode () {
31
+ CODE_EXEC=code
22
32
23
33
_log_ " "
24
34
_log_ " Installing Visual Studio Code..."
@@ -40,7 +50,7 @@ install_vscode() {
40
50
exit 1
41
51
fi
42
52
43
- if ! sudo apt install /tmp/code.deb; then
53
+ if ! sudo apt install -y /tmp/code.deb; then
44
54
_log_ " Failed to install Visual Studio Code."
45
55
rm /tmp/code.deb
46
56
exit 1
@@ -51,15 +61,50 @@ install_vscode() {
51
61
_log_ " Visual Studio Code has been installed."
52
62
}
53
63
64
+ install_vscodium () {
65
+ CODE_EXEC=codium
66
+
67
+ _log_ " "
68
+ _log_ " Installing Visual Studio Code (oss)..."
69
+ _log_ " "
70
+
71
+ if which codium > /dev/null; then
72
+ _log_ " Visual Studio Code (oss) is already installed."
73
+ return
74
+ fi
75
+
76
+ wget -qO - https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/master/pub.gpg \
77
+ | gpg --dearmor \
78
+ | sudo dd of=/usr/share/keyrings/vscodium-archive-keyring.gpg
79
+
80
+ echo ' deb [ signed-by=/usr/share/keyrings/vscodium-archive-keyring.gpg ] https://download.vscodium.com/debs vscodium main' \
81
+ | sudo tee /etc/apt/sources.list.d/vscodium.list
82
+
83
+ if ! sudo apt update; then
84
+ _log_ " Failed to install Visual Studio Code (oss) repo."
85
+ exit 1
86
+ fi
87
+
88
+ if ! sudo apt install -y codium; then
89
+ _log_ " Failed to install Visual Studio Code (oss)."
90
+ exit 1
91
+ fi
92
+
93
+ _log_ " "
94
+ _log_ " Visual Studio Code (oss) has been installed."
95
+ }
96
+
54
97
install_extension () {
55
98
99
+ sudo chown " ${USER} " " ${HOME} /.config"
100
+
56
101
local extension_name=" ${1} "
57
102
local description=" ${2} "
58
103
local ask=" ${3:- false} "
59
104
local response
60
105
local installed_extensions
61
106
62
- readarray installed_extensions < <( code --list-extensions)
107
+ readarray installed_extensions < <( $CODE_EXEC --list-extensions)
63
108
64
109
if [[ " ${installed_extensions[*]} " =~ " ${extension_name} " ]]; then
65
110
_log_ " VSCode extension already installed: ${extension_name} "
@@ -75,7 +120,7 @@ install_extension() {
75
120
_log_ " Installing VSCode extension: ${extension_name} (${description} )..."
76
121
fi
77
122
78
- if ! code --install-extension " ${extension_name} " & > /dev/null; then
123
+ if ! ${CODE_EXEC} --install-extension " ${extension_name} " & > /dev/null; then
79
124
_log_ " Failed to install VSCode extension: ${extension_name} "
80
125
exit 1
81
126
fi
@@ -96,15 +141,118 @@ install_extensions() {
96
141
install_extension ms-python.python " Python support" true
97
142
}
98
143
144
+ # These are VERY helpful for WebKit development, but we won't override existing settings if the user already has them.
145
+ default_settings () {
146
+ if argsparse_is_option_set " no-proprietary" ; then
147
+ VSCODE_CONFIG_PATH=${HOME} /.config/VSCodium/User/
148
+ else
149
+ VSCODE_CONFIG_PATH=${HOME} /.config/Code/User/
150
+ fi
151
+ if [[ ! -e " ${VSCODE_CONFIG_PATH} /settings.json" ]]; then
152
+ mkdir -p " ${VSCODE_CONFIG_PATH} "
153
+ tee " ${VSCODE_CONFIG_PATH} /settings.json" << HERE
154
+ {
155
+ "clangd.arguments": [
156
+ "-header-insertion=never"
157
+ ],
158
+ "editor.renderWhitespace": "trailing",
159
+ "workbench.colorCustomizations": {
160
+ "editorWhitespace.foreground": "#FF0000",
161
+ "editorWhitespace.background": "#FF0000"
162
+ },
163
+ }
164
+ HERE
165
+ echo " Installed default VSCode settings to ${VSCODE_CONFIG_PATH} ."
166
+ else
167
+ echo " There was already a VSCode settings.json (${VSCODE_CONFIG_PATH} ), skipping."
168
+ fi
169
+ }
170
+
171
+ install_xdg () {
172
+ tee " /host/${HOME} /.local/share/applications/code-wkdev.desktop" << HERE
173
+ [Desktop Entry]
174
+ Name=VSCode WKDev
175
+ Comment=Code Editing. Redefined.
176
+ GenericName=Text Editor
177
+ Exec="${WKDEV_SDK_HOST} /scripts/host-only/wkdev-enter" --exec --no-interactive -- $CODE_EXEC %F
178
+ Icon=vscode-wkdev
179
+ Type=Application
180
+ StartupNotify=false
181
+ StartupWMClass=VSCode
182
+ Categories=TextEditor;Development;IDE;
183
+ MimeType=text/plain;inode/directory;application/x-codium-workspace;
184
+ Keywords=vscode;code;vscode;
185
+ Actions=new-empty-window;
186
+
187
+ [Desktop Action new-empty-window]
188
+ Name=New Empty Window
189
+ Exec="${WKDEV_SDK_HOST} /scripts/host-only/wkdev-enter" --exec --no-interactive -- $CODE_EXEC --new-window %F
190
+ Icon=vscode-wkdev
191
+ HERE
192
+ chmod +x " /host/${HOME} /.local/share/applications/code-wkdev.desktop"
193
+ echo " Installed VSCode host launcher"
194
+ }
195
+
196
+ install_xdg_oss () {
197
+ tee " /host/${HOME} /.local/share/applications/codium-wkdev.desktop" << HERE
198
+ [Desktop Entry]
199
+ Name=VSCodium WKDev
200
+ Comment=Code Editing. Redefined.
201
+ GenericName=Text Editor
202
+ Exec="${WKDEV_SDK_HOST} /scripts/host-only/wkdev-enter" --exec --no-interactive -- $CODE_EXEC %F
203
+ Icon=vscodium-wkdev
204
+ Type=Application
205
+ StartupNotify=false
206
+ StartupWMClass=VSCodium
207
+ Categories=TextEditor;Development;IDE;
208
+ MimeType=text/plain;inode/directory;application/x-codium-workspace;
209
+ Keywords=vscodium;codium;vscode;
210
+ Actions=new-empty-window;
211
+
212
+ [Desktop Action new-empty-window]
213
+ Name=New Empty Window
214
+ Exec="${WKDEV_SDK_HOST} /scripts/host-only/wkdev-enter" --exec --no-interactive -- $CODE_EXEC --new-window %F
215
+ Icon=vscodium-wkdev
216
+ HERE
217
+ chmod +x " /host/${HOME} /.local/share/applications/codium-wkdev.desktop"
218
+ echo " Installed VSCodium host launcher"
219
+ }
220
+
221
+ install_icon () {
222
+ mkdir -p " /host/${HOME} /.local/share/icons/hicolor/256x256/apps/"
223
+ cp /usr/share/pixmaps/vscode.png " /host/${HOME} /.local/share/icons/hicolor/256x256/apps/vscode-wkdev.png"
224
+ echo " Installed VSCode host icon."
225
+ }
226
+
227
+ install_icon_oss () {
228
+ mkdir -p " /host/${HOME} /.local/share/icons/hicolor/256x256/apps/"
229
+ cp /usr/share/pixmaps/vscodium.png " /host/${HOME} /.local/share/icons/hicolor/256x256/apps/vscodium-wkdev.png"
230
+ echo " Installed VSCodium host icon."
231
+ }
232
+
99
233
run () {
100
234
101
235
argsparse_parse_options " ${@ } "
102
236
103
- install_vscode
237
+ if argsparse_is_option_set " no-proprietary" ; then
238
+ install_vscodium
239
+ else
240
+ install_vscode
241
+ fi
104
242
105
243
if ! argsparse_is_option_set " no-extensions" ; then
106
244
install_extensions
107
245
fi
246
+
247
+ if argsparse_is_option_set " no-proprietary" ; then
248
+ install_xdg_oss
249
+ install_icon_oss
250
+ else
251
+ install_xdg
252
+ install_icon
253
+ fi
254
+
255
+ default_settings
108
256
}
109
257
110
258
run " ${@ } "
0 commit comments