Accessing gnome-keyring on a mac

One of the more common password managers in linux environments is the gnome-keyring, which is split into a service (gnome-keyring-daemon), and a user interface (most commonly, seahorse).

After a bit of fiddling in the last couple weeks, this system can be compiled to run on a mac, with only a little bit of pain.

On the off chance that it saves someone some pain who’s trying to do the same thing, here are the basic steps I needed to take:

brew install autoconf automake dbus gettext gnome-icon-theme gobject-introspection gtk+3 gtk-doc intltool libffi libgcrypt libtool p11-kit pkg-config vala
brew install libsecret --with-vala

mkdir keyring-buildenv
cd keyring-buildenv

mkdir /usr/local/opt/seahorse

git clone https://github.com/GNOME/gcr
cd gcr
wget https://gist.githubusercontent.com/willscott/fb5d50eba8a2fda17b7ead7d6e6ed98d/raw/5dcdc33f617e1196d5b365dda6b3b8e798f6b644/0001-patch-for-osx-compilation.patch
git apply 0001-patch-for-osx-compilation.patch
glibtoolize
intltoolize
autoreconf
automake -a
PATH=/usr/local/opt/gettext/bin/:$PATH ./configure --enable-valgrind=no --enable-vala=yes --disable-nls --prefix=/usr/local/opt/seahorse
make
make install

cd ..
git clone https://github.com/GNOME/gnome-keyring
cd gnome-keyring
glibtoolize
intltoolize
autoreconf
automake -a
PATH=/usr/local/opt/gettext/bin/:$PATH PKG_CONFIG_PATH=/usr/local/opt/libffi/lib/pkgconfig/:/usr/local/opt/seahorse/lib/pkgconfig/ ./configure --disable-valgrind --without-libcap-ng --disable-doc --disable-pam --disable-ssh-agent --disable-selinux --disable-p11-tests --disable-nls --prefix=/usr/local/opt/seahorse
make
make install

cd ..
git clone
cd seahorse
glibtoolize
intltoolize
autoreconf
automake -a
PATH=/usr/local/opt/gettext/bin/:$PATH PKG_CONFIG_PATH=/usr/local/opt/libffi/lib/pkgconfig/:/usr/local/opt/seahorse/lib/pkgconfig/ ./configure --disable-ldap --disable-hkp --disable-sharing --disable-ssh --disable-pkcs11 --prefix=/usr/local/opt/seahorse/
make

To run, you’ll need to run these components connected by a DBUS instance.
The following script seems to accomplish this:

#!/bin/bash

#dbus session.
HERE=`pwd`
dbus-daemon --session --nofork --address=unix:path=$HERE/unix_listener &
DPID=$!

#keyring daemon
GSETTINGS_SCHEMA_DIR=/usr/local/opt/seahorse/share/glib-2.0/schemas/ DBUS_SESSION_BUS_ADDRESS=unix:path=$HERE/unix_listener ./gnome-keyring/gnome-keyring-daemon --start --foreground &
KPID=$!

#prompter
GSETTINGS_SCHEMA_DIR=/usr/local/opt/seahorse/share/glib-2.0/schemas/ DBUS_SESSION_BUS_ADDRESS=unix:path=$HERE/unix_listener ./gcr/gcr-prompter &

#seahorse
GSETTINGS_SCHEMA_DIR=/usr/local/opt/seahorse/share/glib-2.0/schemas/ DBUS_SESSION_BUS_ADDRESS=unix:path=$HERE/unix_listener ./seahorse/seahorse

# cleanup
kill $KPID
kill $DPID