#!/bin/sh
if [ -f /home/$USER/.config/alteratio/start.desktop ]
then
clear
else
/usr/bin/theme-engine /usr/share/alteratio/themes/Alteratio.s7t
fi


usr_conf_dir="alteratio"
### input update notification configuration file ###
source /home/$USER/.config/$usr_conf_dir/theme.s7t
source /home/$USER/.config/$usr_conf_dir/update-notification.cfg

menu_icon=$(yad --width=600 --height=600 --file-selection --filename=/usr/share/lxpanel/images/menu-icons/)


########################################################################
###                write Alteratio theme config files                ###
########################################################################
### the actual theme file ###
cat > /home/$USER/.config/alteratio/theme.s7t << EOF
panel_background="$panel_background"
panel_opacity="$panel_opacity"
panel_tint="$panel_tint"
panel_height="$panel_height"
panel_position="$panel_position"
panel_font_color="$panel_font_color"
panel_icon_size="$panel_icon_size"
panel_desktop_icon="$panel_desktop_icon"
panel_taskbar_flat="$panel_taskbar_flat"
panel_taskbar_iconsonly="$panel_taskbar_iconsonly"
panel_taskbar_group="$panel_taskbar_group"
panel_layout="$panel_layout"
panel_type="$panel_type"
menu_icon="$menu_icon"
system_icon="$system_icon"
system_widget="$system_widget"
system_cursor="$system_cursor"
system_background="$system_background"
winman_theme="$winman_theme"
default_browser="$default_browser"
EOF


########################################################################
###                     change whisker menu icon                     ###
########################################################################
cat > /home/$USER/.config/alteratio/start.desktop << EOF
[Desktop Entry]
GenericName=Start
Name=Start
Comment=Start
Icon=$menu_icon
Exec=xfce4-popup-whiskermenu
Terminal=false
Type=Application
Categories=GTK;Settings;HardwareSettings;
NoDisplay=true
EOF


########################################################################
###                         restart lxpanel                          ###
########################################################################
lxpanelctl restart