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