#!/bin/sh
#
# Djibian config — use gpg-agent as the SSH agent.
#
# Copyright © 2025-2026 foopgp <info@foopgp.org>
# SPDX-License-Identifier: GPL-3.0-only
#
# systemd user environment-generator (see systemd.environment-generator(7)).
# Exports SSH_AUTH_SOCK pointing to gpg-agent's ssh socket, so any process
# in the graphical session (X or Wayland via systemd-logind) authenticates
# over SSH using the keys held by the OpenPGP smartcard / gpg-agent.
#
# The agent itself is auto-spawned by gpg-agent's first-use semantics, so
# no explicit `gpgconf --launch gpg-agent` is needed here.
#
# Mirrored by /etc/X11/Xsession.d/95gpg4ssh_env for X sessions started
# without systemd user (older display managers). Both paths are idempotent.

sock=$(gpgconf --list-dirs agent-ssh-socket 2>/dev/null)

[ -n "$sock" ] && echo "SSH_AUTH_SOCK=$sock"

exit 0
