Commits

Etienne Perot committed cc7e4e9

Initial commit (and probably the last, not sure what would need changing.)

  • Participants

Comments (0)

Files changed (6)

+*.tar.*
+pkg
+src
+            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+                    Version 2, December 2004
+
+ Copyright (C) 2012 Etienne Perot <etienne at perot dot me>
+
+ Everyone is permitted to copy and distribute verbatim or modified
+ copies of this license document, and changing it is allowed as long
+ as the name is changed.
+
+            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. You just DO WHAT THE FUCK YOU WANT TO.
+# Maintainer: Etienne Perot <etienne[at]perot[dot]me>
+
+pkgname=kde-agent-zsh
+pkgver=20121218
+pkgrel=1
+pkgdesc="Use ZSH environment variables to determine which SSH/GPG agent to use in KDE applications."
+arch=('any')
+url='https://github.com/EtiennePerot/kde-agent-zsh'
+license=('WTFPL')
+provides=('kde-agent')
+conflicts=('kde-agent')
+depends=('pinentry' 'openssh' 'qt')
+source=('gpg-ssh-agent.sh'
+        'gpg-ssh-agent-shutdown.sh')
+sha512sums=('518b57aa29ee52a3bd059f63c661edce6864d8a95b9cfec14eb8ee537184492805de06225ab6d64cf225b847e2619fa2e2379d37987e04b99878bf93f96cf427'
+            'a63619823bd235d9450badc0d083fb8d38b252d28230c49233dbda5a33bf5863a7844ea48afa38643b0d0edce54aa4508aa45ac932a3f2d86ccc6af39464807a')
+package() {
+  cd "${srcdir}"
+  install -d "${pkgdir}"/etc/kde/env
+  install -D -m755 gpg-ssh-agent.sh "${pkgdir}"/etc/kde/env/
+
+  install -d "${pkgdir}"/etc/kde/shutdown
+  install -D -m755 gpg-ssh-agent-shutdown.sh "${pkgdir}"/etc/kde/shutdown/
+}
+kde-agent-zsh
+=============
+
+Purpose
+-------
+Arch has a [`kde-agent`][kde-agent] package which starts its own [GPG]/[SSH]
+agent on [KDE] startup.
+
+This package replaces `kde-agent`. Instead of starting its own set of agents,
+it runs zsh in interactive mode, grabs the GPG/SSH agent-related environment
+variables, and uses those instead. This way you don't end up with four agents.
+
+Usage
+-----
+Make sure that the following environment variables are exported in your ZSH
+environment:
+
+* `SSH_AUTH_SOCK`
+* `SSH_AGENT_PID`
+* `GPG_AGENT_INFO`
+* `GPG_TTY` (optional)
+
+Additionally, if you keep your environment variables stored in stateful files,
+make sure the following environment variables are exported as well:
+
+* `GPG_AGENT_ENV_FILE`
+* `SSH_AGENT_ENV_FILE`
+
+If exported, the files they refer to will be deleted on shutdown. This is not
+guaranteed, however (since you may have a power outage or something), so make
+sure that your ZSH startup script also takes care of ignoring those if they
+contain stale values.
+
+License
+-------
+kde-agent-zsh is licensed under the [WTFPL]. Enjoy.
+
+[kde-agent]: https://www.archlinux.org/packages/extra/any/kde-agent/
+[GPG]: https://en.wikipedia.org/wiki/GNU_Privacy_Guard
+[SSH]: https://en.wikipedia.org/wiki/OpenSSH
+[KDE]: https://kde.org/
+[WTFPL]: http://sam.zoy.org/wtfpl/

File gpg-ssh-agent-shutdown.sh

+#!/bin/sh
+
+if [ -n "$SSH_AGENT_PID" ]; then
+	kill "$SSH_AGENT_PID"
+	unset SSH_AGENT_PID SSH_AUTH_SOCK
+fi
+
+if [ -n "$SSH_AGENT_ENV_FILE" ]; then
+	rm -f "$SSH_AGENT_ENV_FILE"
+	unset SSH_AGENT_ENV_FILE
+fi
+
+if [ -n "$GPG_AGENT_INFO" ]; then
+	GPG_AGENT_PID=`echo "$GPG_AGENT_INFO" | cut -d: -f2` && kill "$GPG_AGENT_PID" ||:
+	unset GPG_AGENT_INFO GPG_TTY
+fi
+
+if [ -n "$GPG_AGENT_ENV_FILE" ]; then
+	rm -f "$GPG_AGENT_ENV_FILE"
+	unset GPG_AGENT_ENV_FILE
+fi

File gpg-ssh-agent.sh

+#!/usr/bin/env bash
+
+zshEnv=$(/usr/bin/env zsh -ic env)
+for varName in SSH_AUTH_SOCK SSH_AGENT_PID GPG_AGENT_INFO GPG_TTY GPG_AGENT_ENV_FILE SSH_AGENT_ENV_FILE; do
+	if echo "$zshEnv" | grep "^$varName=" &> /dev/null; then
+		eval export $(echo "$zshEnv" | grep "^$varName=")
+	fi
+done