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