-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
6 changed files
with
52 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
.Xauthority | ||
.Xauthority | ||
.env | ||
.host/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
source .devcontainer/.host/.env | ||
|
||
# override display flag for mac | ||
if [[ $HOST_OS == darwin ]]; then | ||
echo "Setting up DISPLAY override for macOS..." | ||
cat <<EOF >> /root/.bashrc | ||
if [ -n "\$DISPLAY" ]; then | ||
DISPLAY_NUM=\$(echo "\$DISPLAY" | awk -F: '{print \$NF}') | ||
export DISPLAY=host.docker.internal:\$DISPLAY_NUM | ||
fi | ||
EOF | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
# setup safe directories for submodules | ||
SUBMODULE_DIRS=$(git config --file .gitmodules --get-regexp path | awk '{ print $2 }') | ||
for DIR in $SUBMODULE_DIRS; do | ||
git config --global --add safe.directory "$PWD/$DIR" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file was deleted.
Oops, something went wrong.