# This shell script is run before Openbox launches.
# Environment variables set here are passed to the Openbox session.

# Start DBUS session.
if [ ! "$DBUS_SESSION_BUS_ADDRESS" ]; then
	dbus-launch --sh-syntax --exit-with-session &
fi

# Start PCmanFM as daemon for Wallpaper and desktop icons.
#pcmanfm -d &

# Start the Freedesktop panel standard menu.
#lxpanel --profile slitaz &

# Packages update notification.
#tazpkg-notify &

# Start Parcellite clipboard manager.
#parcellite &

# Launch Xpad desktop notes utility.
#xpad &

# Desktop effects composer.
#xcompmgr -c -r 10 &

# Wallpaper: same image as the LXTaz desktop (lxtaz-files), else the
# SliTaz default. Only run by openbox-session: LXDE/LXTaz start openbox
# without this autostart and lxtaz-files draws the desktop there.
conf="${XDG_CONFIG_HOME:-$HOME/.config}/lxtaz/files.conf"
wp=$(sed -n 's/^wallpaper=//p' "$conf" 2>/dev/null)
mode=$(sed -n 's/^wallpaper-mode=//p' "$conf" 2>/dev/null)
bg=$(sed -n 's/^background=//p' "$conf" 2>/dev/null)
[ -f "$wp" ] || wp=/usr/share/images/slitaz-dark.jpg
case "$mode" in
	fit) opt=-full ;;
	center) opt=-center ;;
	tile) opt=-tile ;;
	stretch) opt=-fill ;;
	*) opt=-cover ;;
esac
if [ "$mode" = "color" ]; then
	hsetroot -solid "${bg:-#0b0d10}" &
else
	hsetroot -solid "${bg:-#0b0d10}" $opt "$wp" &
fi

# Wbar2 icon bar.
#$(sleep 3 && wbar) &
