Skip to content

Instantly share code, notes, and snippets.

@pweinzettel
Created August 28, 2020 00:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pweinzettel/6eb877244cd00c173880b06156b961b0 to your computer and use it in GitHub Desktop.
Save pweinzettel/6eb877244cd00c173880b06156b961b0 to your computer and use it in GitHub Desktop.
Run Virtual Box (or any other gui software) on separate virtual terminal
#!/bin/bash
# To get the vmid, use:
# VBoxManage list vms
VM="{3b019d6d-16d1-4a8b-909d-8c79e53abd2d}";
XN=4;
XS=/tmp/.X11-unix;
# Create a new X server on vt8
if [ ! -S ${XS}/X${XN} ]; then
X -quiet -nolisten tcp -noreset :${XN} vt8 &
fi
echo -en "Waiting for X server: "
while [ ! -S ${XS}/X${XN} ]; do
echo -en '.';
sleep 1;
done
echo ' done!';
export DISPLAY=:${XN}
/usr/lib/virtualbox/VirtualBoxVM --fullscreen --startvm "${VM}"
echo -en "Stopping X server: "
while [ -S ${XS}/X${XN} ]; do
kill $(ps aux | grep "Xorg.*vt8$" | awk {'print$2'}) >/dev/null 2>&1
echo -en '.';
sleep 1;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment