#!/bin/sh
#    Sourced by the xmonad gdm/lightdm session.  Initially from
#    /usr/share/doc/xmonad/README.Debian

# Configuration options:

# fbpanel is a plausible alternative to trayer, but it's not as good as it should be.
# stalonetray would be worth investigating.
systemTray=trayer

if_defined () {
    if [ -x $1 ]; then $* & fi
}
if_defined_else () {
    if [ -x $1 ]; then $1 & elif [ -x $2 ]; then $2 & fi
}

# This is used by GTK applications to get their defaults.
if_defined gnome-settings-daemon

if [ -x /usr/bin/gnome-keyring-daemon ]; then
    # This combines ssh-agent and gpg-agent for key management.
    # $(...) sources the command output to set variables.
    $(gnome-keyring-daemon --start --daemonize)
fi

# This is used by X toolkit applications, notably xterm, to get their defaults.
# They will also read .Xdefaults-<hostname> for local overrides; I use this to
# set the foreground color to green on servers and amber on cloud hosts.
if [ -e  $HOME/.Xdefaults ]; then
    xrdb -merge $HOME/.Xdefaults
fi

# Use a solid blue background to indicate that something is happening.
# Also makes it easier for VGA monitors to sync up.
xsetroot -xcf /usr/share/icons/Adwaita/cursors/left_ptr 16 -solid blue

if [ trayer = "$systemTray" ]; then
    # This contains the indicators, most notably the network manager applet.
    # The width is set to 10% of the screen to leave room for xmobar, which
    # is started by xmonad so that it can pipe its log into it.
    trayer --edge top --align right --SetDockType true\
	   --SetPartialStrut true --expand true\
	   --widthtype request --width 10 --height 24\
	   --transparent true --tint 0x000000 &
else
    $systemTray &
fi
sleep 1

if_defined /usr/bin/classicmenu-indicator
if_defined_else /usr/bin/xfce4-power-manager /usr/bin/gnome-power-manager
if_defined /usr/bin/nm-applet -applet --sm-disable 

# xscreensaver on gnome-oriented distros is old and crufty.  gnome-screensaver
# is bland, but it's reliable and has a "switch user" feature to bring up an
# alternate session, which is handy when sharing a computer.
if_defined gnome-screensaver

# I like to see directories listed in ASCII order, with dotfiles on top, then
# uppercase, then lowercase.  I tend to start directory names with uppercase
# letters to take advantage of this.
export LC_COLLATE=C

# Apparently any use of xmodmap on Ubuntu turns off VT switching!
# If you need to make right alt into Super, use Gnome's  keyboard control
# panel applet to say that right alt = altGr
#if [ -e $HOME/.xmonad/.Xmodmap ]; then xmodmap $HOME/.xmonad/.Xmodmap; fi


