improve/fix Xsession integration
# This file is sourced by Xsession(5), not executed.
-OIDCAGENT=/usr/bin/oidc-agent
-OIDCAGENTARGS=
-OIDC_AGENT_XSESSION_CONFIG_FILE="${HOME}/.config/oidc-agent/oidc-agent-Xsession.options"
+# Do not edit this file. To configure Xsession integration create a file called
+# oidc-agent-Xsession.options in your oidc-agent directory.
+# To disable Xsession integration use the START_AGENT_WITH_XSESSION variable.
+# Use OIDC_AGENT_ARGS to set the arguments that should be used when the agent is
+# started.
+OIDC_AGENT=/usr/bin/oidc-agent
+OIDC_AGENT_ARGS=
START_AGENT_WITH_XSESSION="True"
+
+XSESSION_OPTIONS_FILENAME="oidc-agent-Xsession.options"
+
+AGENT_DIR=
+
+# Find oidc-agent dir
+if [ ! -z ${OIDC_CONFIG_DIR+x} ]; then
+ if [ -d "${OIDC_CONFIG_DIR}" ]; then
+ AGENT_DIR="${OIDC_CONFIG_DIR}"
+ fi
+fi
+if [ -z "${AGENT_DIR}" ]; then
+ if [ -d "${HOME}/.config" ]; then
+ AGENT_DIR="${HOME}/.config/oidc-agent"
+ fi
+fi
+if [ -z "${AGENT_DIR}" ]; then
+ AGENT_DIR="${HOME}/.oidc-agent"
+fi
+
+OIDC_AGENT_XSESSION_CONFIG_FILE="${AGENT_DIR}/${XSESSION_OPTIONS_FILENAME}"
+
# If there is a config file, source it.
-# It may overwrite # START_AGENT_WITH_XSESSION
-if [ -x "${OIDC_AGENT_XSESSION_CONFIG_FILE}" ]; then
+# It may overwrite START_AGENT_WITH_XSESSION and OIDC_AGENT_ARGS
+if [ -f "${OIDC_AGENT_XSESSION_CONFIG_FILE}" ]; then
. ${OIDC_AGENT_XSESSION_CONFIG_FILE}
fi
if [ "x${START_AGENT_WITH_XSESSION}" == "xTrue" ]; then
- if [ -x "$OIDCAGENT" ] && [ -z "$OIDC_SOCK" ]; then
- eval `$OIDCAGENT $OIDCAGENTARGS`
+ echo "$OIDC_AGENT $OIDC_AGENT_ARGS"
+ if [ -x "$OIDC_AGENT" ] && [ -z "$OIDC_SOCK" ]; then
+ eval `$OIDC_AGENT $OIDC_AGENT_ARGS`
fi
fi
