Skip to content

Instantly share code, notes, and snippets.

@mrdomino
Created December 31, 2016 23:16
Show Gist options
  • Save mrdomino/79d4993427c0a07688a219c8121f1d40 to your computer and use it in GitHub Desktop.
Save mrdomino/79d4993427c0a07688a219c8121f1d40 to your computer and use it in GitHub Desktop.
OpenBSD script to run chrome as a separate user in a Xephyr window
#!/bin/sh
set -eux
NDISPLAY=:13
if [ $# -ge 1 ]
then
case $1 in
:*)
NDISPLAY=$1
shift
;;
esac
fi
Xephyr $NDISPLAY -host-cursor -no-host-grab -resizeable &
sleep 0.5
ps -p $! || exit 1
trap "kill $!" EXIT
export DISPLAY=$NDISPLAY
tmpfile=$(mktemp)
xauth -q -f $tmpfile generate $DISPLAY . trusted
xauth_data=$(xauth -f $tmpfile nlist $DISPLAY)
rm -f $tmpfile
DOAS_XAUTH="xauth -q remove $DISPLAY ; echo $xauth_data | xauth nmerge - ;"
export DOAS_XAUTH
doas -u firefox sh -c 'export HOME=/home/firefox ; cd $HOME ; eval $DOAS_XAUTH ; unset DOAS_XAUTH ; cwm & /usr/local/bin/'"$(basename $0) $@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment