#!/bin/sh
#
# ~/.xinitrc
#
# Executed by startx (run your window manager from here)
WM=i3
if (( $# == 1 ))
then
  WM=$1
fi

if [ -d /etc/X11/xinit/xinitrc.d ]; then
  for f in /etc/X11/xinit/xinitrc.d/*; do
    [ -x "$f" ] && . "$f"
  done
  unset f
fi

export EDITOR="vim"
export CUPS_GSSSERVICENAME=HTTP

[[ -f ~/.Xresources ]] && xrdb -merge ~/.Xresources

volnoti &
owncloud &

rm -f "~/${WM}.log.old"
mv -f "~/${WM}.log" "~/${WM}.log.old"
rm -f "~/${WM}.log"
rm -f "~/${WM}.log"

if [ "$WM" = "i3" ]; then
    . ~/.i3initrc
else
    exec $WM >> "~/${WM}.log" 2>&1
fi
