# This file is sourced by Xsession(5), not executed.

PROG="/usr/bin/xbindkeys"
NOAUTO="${HOME}/.xbindkeys.noauto"

# This file autostarts xbindkeysrc if the user (or system) has a config
# for it AND does NOT Have a .xbindkeys.noauto in his homedir.

# we only run if there is no NOAUTO file
if ! [ -f "${NOAUTO}" ] && [ -x "${PROG}" ]; then
    # User config wins over system config
    # guile config wins over classic config
    for cfile in "/etc/xbindkeysrc" "$HOME/.xbindkeysrc" "$HOME/.xbindkeysrc.scm"; do
        if [ -f "${cfile}" ] || [ -L "${cfile}" ]; then
            CONF="${cfile}"
        fi
    done

    # Run $PROG - if it has been configured
    if [ -n "${CONF}" ]; then
        $PROG -f $CONF
    fi
fi
