#!/bin/dash
# Launch freedesktop's autostart desktop files
# JakeSFR 2016
#
# Note: we use "rox" because our xdg-open can't properly launch desktop files

GAP_DELAY=0.2           # delay between starting subsequent files
SYSTEM_AUTOSTART_DIR=$XDG_CONFIG_DIRS/autostart
USER_AUTOSTART_DIR=$XDG_CONFIG_HOME/autostart

# run global Autostart files
if [ -d $SYSTEM_AUTOSTART_DIR ]; then
	for p in $SYSTEM_AUTOSTART_DIR/*.desktop; do
		if [ -e $p ]; then
			rox $p & sleep $GAP_DELAY
		fi
	done
fi

# run per-user Autostart files
if [ -d $USER_AUTOSTART_DIR ]; then
	for p in $USER_AUTOSTART_DIR/*.desktop; do
		if [ -e $p ]; then
			rox $p & sleep $GAP_DELAY
		fi
	done
fi
