#!/bin/ash

# allow applications running as spot to talk to labwc
SPOT_RUNTIME_DIR=`run-as-spot sh -c 'mkdir -p $XDG_RUNTIME_DIR && echo $XDG_RUNTIME_DIR'`
for F in $WAYLAND_DISPLAY $WAYLAND_DISPLAY.lock; do
	umount -l $SPOT_RUNTIME_DIR/$F 2>/dev/null
	touch $SPOT_RUNTIME_DIR/$F
	chown spot:spot $XDG_RUNTIME_DIR/$F
	mount --bind $XDG_RUNTIME_DIR/$F $SPOT_RUNTIME_DIR/$F
done

echo "add $DISPLAY . `mcookie`" | xauth -q -f ~/.Xauthority
cp -f ~/.Xauthority /home/spot/.Xauthority
chown spot:spot /home/spot/.Xauthority

# desktop settings
[ -e "$XDG_CONFIG_HOME/wmonitors/wmon_cmd" ] && . $XDG_CONFIG_HOME/wmonitors/wmon_cmd

. /etc/rc.d/wl_func
apply_gtk_settings

# pass environment variables to D-Bus activated applications like Blueman
run-as-spot dbus-update-activation-environment DISPLAY WAYLAND_DISPLAY XDG_CURRENT_DESKTOP

# show all buttons in Firefox CSD
gsettings set org.gnome.desktop.wm.preferences button-layout "appmenu:minimize,maximize,close"
run-as-spot gsettings set org.gnome.desktop.wm.preferences button-layout "appmenu:minimize,maximize,close"

xdg_autostart.sh
/usr/sbin/delayedrun &
