devcontainer: expose host config, fix mac screen issues (#29932)

* export host config via .host/.env file. fix mac display issues

* append instead of replace for bashrc

* Log when mac display override happens

* Update xauthority path in json
This commit is contained in:
Kacper Rączy
2023-09-15 14:00:24 -07:00
committed by GitHub
parent 09bef0a165
commit dd26a1faad
6 changed files with 52 additions and 21 deletions
+24
View File
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
# setup .host dir
mkdir -p .devcontainer/.host
# setup links to Xauthority
XAUTHORITY_LINK=".devcontainer/.host/.Xauthority"
rm -f $XAUTHORITY_LINK
if [[ -z $XAUTHORITY ]]; then
echo "XAUTHORITY not set. Fallback to ~/.Xauthority ..."
if ! [[ -f $HOME/.Xauthority ]]; then
echo "~/.XAuthority file does not exist. GUI tools may not work properly."
touch $XAUTHORITY_LINK # dummy file to satisfy container volume mount
else
ln -sf $HOME/.Xauthority $XAUTHORITY_LINK
fi
else
ln -sf $XAUTHORITY $XAUTHORITY_LINK
fi
# setup host env file
HOST_INFO_FILE=".devcontainer/.host/.env"
SYSTEM=$(uname -s | tr '[:upper:]' '[:lower:]')
echo "HOST_OS=\"$SYSTEM\"" > $HOST_INFO_FILE