229cbf
#!/usr/bin/bash
229cbf
# Run wayland compositor and set WAYLAND_DISPLAY env variable
229cbf
229cbf
set -x
229cbf
229cbf
echo export DESKTOP_SESSION=gnome > $HOME/.xsessionrc
229cbf
echo export XDG_CURRENT_DESKTOP=GNOME > $HOME/.xsessionrc
229cbf
echo export XDG_SESSION_TYPE=wayland >> $HOME/.xsessionrc
229cbf
229cbf
# Turn off the screen saver and screen locking
229cbf
gsettings set org.gnome.desktop.screensaver idle-activation-enabled false
229cbf
gsettings set org.gnome.desktop.screensaver lock-enabled false
229cbf
gsettings set org.gnome.desktop.screensaver lock-delay 3600
229cbf
229cbf
# Disable the screen saver
229cbf
# This starts the gnome-keyring-daemon with an unlocked login keyring. libsecret uses this to
229cbf
# store secrets. Firefox uses libsecret to store a key that protects sensitive information like
229cbf
# credit card numbers.
229cbf
if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then
229cbf
    # if not found, launch a new one
229cbf
    eval `dbus-launch --sh-syntax`
229cbf
fi
229cbf
eval `echo '' | /usr/bin/gnome-keyring-daemon -r -d --unlock --components=secrets`
229cbf
229cbf
if [ -z "$XDG_RUNTIME_DIR" ]; then
229cbf
  export XDG_RUNTIME_DIR=$HOME
229cbf
fi
229cbf
229cbf
. xvfb-run -s "-screen 0 1600x1200x24" -n 80 mutter --display=:80 --wayland --nested &
229cbf
export DISPLAY=:80
229cbf
229cbf
if [ -z "$WAYLAND_DISPLAY" ] ; then
229cbf
  export WAYLAND_DISPLAY=wayland-0
229cbf
else
229cbf
  export WAYLAND_DISPLAY=wayland-1
229cbf
fi
229cbf
sleep 10
229cbf
retry_count=0
229cbf
max_retries=5
229cbf
until [ $retry_count -gt $max_retries ]; do
229cbf
  if [ -S "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY" ]; then
229cbf
    retry_count=$(($max_retries + 1))
229cbf
  else
229cbf
    retry_count=$(($retry_count + 1))
229cbf
    echo "Waiting for Mutter, retry: $retry_count"
229cbf
    sleep 2
229cbf
  fi
229cbf
done
229cbf
229cbf
env | grep "DISPLAY"