#!/bin/sh
# hh-desktop-init - point the user's openbox autostart at the LIVE system
# autostart so desktop-config updates ALWAYS take, with no per-user copies to
# go stale. Called from the X session entrypoint before openbox-session.
#
# Why only the autostart: openbox-autostart (run by openbox-session) reads only
# /etc/xdg/openbox/autostart or ~/.config/openbox/autostart -- NOT
# XDG_CONFIG_DIRS -- so the autostart is the single desktop file that must live
# under ~/.config. Everything else resolves live from /usr/local/etc/xdg via
# XDG_CONFIG_DIRS (set by the X session): openbox rc.xml/menu.xml and tint2rc;
# conky is launched by the autostart with an explicit -c path. So none of those
# need a per-user copy.
#
# We make ~/.config/openbox/autostart a SYMLINK to the system autostart (not a
# copy), so a package update to the autostart is picked up with no re-seed.
# A pre-existing non-symlink here is treated as legacy seeded state and migrated
# to the symlink.
SYS=/usr/local/etc/xdg/openbox/autostart
CFG="${XDG_CONFIG_HOME:-$HOME/.config}/openbox"
mkdir -p "$CFG" 2>/dev/null || exit 0
if [ "$(readlink "$CFG/autostart" 2>/dev/null)" != "$SYS" ]; then
rm -f "$CFG/autostart" 2>/dev/null
ln -sf "$SYS" "$CFG/autostart" 2>/dev/null
fi
exit 0