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