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