#!/bin/sh
#
# fluxbox startup-script:
#
# Lines starting with a '#' are ignored.

# Applications you want to run with fluxbox.
# MAKE SURE THAT APPS THAT KEEP RUNNING HAVE AN ''&'' AT THE END.

#setup default translated mx-fluxbox menu
#only do on first setup of new user
#upgrades are handled by mxflux_install.sh script

# localize fluxbox menu
# to reset default localized menu configuration, delete ~/.fluxbox/menu-chkd
# logout, then log back in to fluxbox session
localize_fluxbox_menu-mx

# mx-welcome if configured to autostart
if [ -e $HOME/.config/autostart/mx-welcome.desktop ]; then
# launch mx-welcome
(sleep 5; /usr/bin/mx-welcome) &
fi

# User folders update
xdg-user-dirs-update
# Update common folders names to match current locale
xdg-user-dirs-gtk-update

#start a compositor if using complicated conkies
#compton &

#add system monitors 
#gkrellm &

# arandr genrated screenlayout 
# before conky

# export Qt variables
export QT_QPA_PLATFORMTHEME=gtk2
export QT_PLATFORMTHEME=gtk2
export QT_PLATFORM_PLUGIN=gtk2

# add selected tint2 panel
tint2session 

# add desktop icons
idesktoggle idesk on 1>/dev/null 2>&1 &

# add root access
/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1 &

#set the default dock
$HOME/.fluxbox/scripts/DefaultDock.mxdk

#conky to follow conky toggle settings
$HOME/.fluxbox/scripts/conkystart

#place network manager on the toolbar
nm-applet &

#start pulseaudio before volumeicon so unmute works
start-pulseaudio-x11 &
sleep 2
volumeicon -c volumeicon-fluxbox & 

#place clipboard on the toolbar
xfce4-clipman &

#put brightness controller and battery monitor on toolbar
#tint2 has its own battery widget so this is unnecessaary
#xfce4-power-manager &

# start user accessibility bus - if not already running
/usr/libexec/at-spi-bus-launcher --launch-immediately  &

#update app  menu if it doesn't exist
if [ ! -f $HOME/.fluxbox/submenus/full_menu ]; then
    command -v mxfb-menu-generator && mxfb-menu-generator
fi

#get last background selected
#~/.fehbg
nitrogen --restore

# Debian-local change:
#   - fbautostart has been added with a quick hack to check to see if it
#     exists. If it does, we'll start it up by default.
which fbautostart > /dev/null
if [ $? -eq 0 ]; then
    fbautostart
fi

# put apt-notifier on the toolbar
(sleep 6; /usr/bin/apt-notifier) &

# start spice-vdagent in KVM/Qemu 
if [ -x /usr/bin/spice-vdagent ]; then
   pidof -q spice-vdagentd && /usr/bin/spice-vdagent
fi

# And last but not least we start fluxbox.
# Because it is the last app you have to run it with ''exec'' before it.

exec fluxbox
# or if you want to keep a log:
# exec fluxbox -log ~/.fluxbox/log
