Skip to content

Commit 2abd09f

Browse files
committed
autolaunch Xquartz on mac
1 parent 8474567 commit 2abd09f

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

launch_X.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
# Check if the operating system is macOS
4+
if [[ "$(uname)" != "Darwin" ]]; then
5+
echo "This script is designed to run on macOS only."
6+
exit 1
7+
fi
8+
9+
# Check if XQuartz is installed
10+
if ! command -v Xquartz &> /dev/null && ! command -v xterm &> /dev/null; then
11+
echo "XQuartz is not installed."
12+
echo "You can install XQuartz from: https://www.xquartz.org/"
13+
echo "After installation, please rerun this script."
14+
exit 1
15+
fi
16+
17+
echo "Launching XQuartz (if not open already)..."
18+
open -a XQuartz
19+
sleep 2
20+
echo "Configuring xhost for localhost"
21+
xterm -e "xhost +localhost"
22+
sleep 2
23+
echo "Killing any xterm sessions..."
24+
pkill -x xterm
25+
echo "Done"

run-func.sh

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ if [[ "$(docker images -q ${IMAGE_TAG} 2> /dev/null)" == "" ]]; then
3232
docker build --pull --build-arg GIT_REPO=${GIT_REPO} --target ${IMAGE_TARGET} -t ${IMAGE_TAG} .
3333
fi
3434

35+
./launch_X.sh
36+
3537
# run container if not created, otherwise attach to existing
3638
if [[ "$(docker container ls -qa --filter name=${CONTAINER_NAME} 2> /dev/null)" == "" ]]; then
3739
echo "Creating and running container..."

0 commit comments

Comments
 (0)