#!/bin/sh -e
# Including helpers
. /boot/ods-install/helpers.sh

# Sets ods user
log "Setting ods user ..."

ODS_USR=pi

# Removes boot message
log "Setting boot options in cmdline.txt ..."

# Something previsously broken, revert and restart
# if [ ! -f /boot/cmdline.bak ]; then
#     cp /boot/cmdline.txt /boot/cmdline.bak
#     cp -f /boot/ods-install/resources/cmdline.txt /boot/cmdline.txt
# fi

# Sets up LXDE autostart
log "Configuring LXDE autostart ..."

if [ -d /home/$ODS_USR/.config/lxsession/LXDE/ ]; then
    cp -f /boot/ods-install/resources/autostart /home/$ODS_USR/.config/lxsession/LXDE/
    chown $ODS_USR /home/$ODS_USR/.config/lxsession/LXDE/autostart
else
    log "Configuring LXDE autostart ... Error! Directory not found."
fi

# Hides trash icon
log "Configuring LXDE desktop (Hiding trash icon) ..."

if [ -d /home/$ODS_USR/.config/pcmanfm/LXDE/ ]; then
    cp -f /boot/ods-install/resources/desktop-items-0.conf /home/$ODS_USR/.config/pcmanfm/LXDE/
    chown $ODS_USR /home/$ODS_USR/.config/pcmanfm/LXDE/desktop-items-0.conf
else
    log "Configuring LXDE desktop (Hiding trash icon) ... Error! Directory not found."
fi

# Hides task bar
log "Configuring LXDE desktop (Hiding task bar) ..."

if [ -d /home/$ODS_USR/.config/lxpanel/LXDE/panels/ ]; then
    cp -f /boot/ods-install/resources/panel /home/$ODS_USR/.config/lxpanel/LXDE/panels/
    chown $ODS_USR /home/$ODS_USR/.config/lxpanel/LXDE/panels/panel
else
    log "Configuring LXDE desktop (Hiding task bar) ... Error! Directory not found."
fi

# Puts a splash screen with plymouth
log "Putting a splash screen with plymouth ..."

cp -rf /boot/ods-install/resources/optech /usr/share/plymouth/themes
plymouth-set-default-theme optech
