#!/bin/sh
#
# fluxbox startup-script:

# Change your keymap:
xmodmap "~/.Xmodmap"

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

# Start DBUS session bus:
if [ -z "\$DBUS_SESSION_BUS_ADDRESS" ]; then
   dbus-launch --sh-syntax --exit-with-session
fi

(sleep 1 && [ -x /usr/bin/pcmanfm ] && dbus-launch pcmanfm --desktop) &
([ -x /usr/bin/batti ] && dbus-launch batti) &
# Create the apps submenu if it's not there
[ ! -f ~/.fluxbox/xdg_menu ] && \
	[ -x /usr/bin/xdgmenumaker ] && \
	xdgmenumaker -f fluxbox --no-submenu > ~/.fluxbox/xdg_menu

# Load the last used wallpaper
if [ -x /usr/bin/feh ] && [ -x ~/.fehbg ]; then
	~/.fehbg
else
	fbsetbg -l
fi

# Only run fbxkb when there are more than 1 available layouts
setxkbmap -query | grep "^layout:" | sed "s/^layout: *//" | \
	grep -q "," && [ -x /usr/bin/fbxkb ] && fbxkb &

# Create XDG user dirs
[ -x /usr/bin/xdg-user-dirs-update ] && xdg-user-dirs-update &
[ -x /usr/bin/parcellite ] && parcellite &
[ -x /usr/bin/wicd-gtk ] && wicd-gtk -t &
[ -x /usr/bin/volumeicon ] && volumeicon &
[ -x /usr/bin/batti ] && batti &
[ -x /usr/bin/salix-update-notifier ] && salix-update-notifier &
[ -x /usr/bin/xscreensaver ] && xscreensaver -nosplash &
[ -x /usr/bin/fbpanel ] && fbpanel) &

# 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
#exec ck-launch-session dbus-launch fluxbox
# or if you want to keep a log:
# exec fluxbox -log "~/.fluxbox/log"
