~tardypad/dotfiles

b905e90b851acb36110aa390b388f4c4235493ac — Damien Tardy-Panis 4 months ago a7edcdb
Remove script and config related to yubikey opengpg requiring touch

We disabled the touch again. It was annoying but manageable so far even
with the following issues:
- required a touch for each mail sending in aerc (could have been
  patched there though)
- not all cases for pass commands were covered
- made it quite impossible to use `pass grep`

However it will make it impossible to run some regular background
command for mail fetching via mbsync.

We'll just keep the touch for the OATH part.
5 files changed, 2 insertions(+), 112 deletions(-)

M files/docs/shell/Makefile
D files/docs/shell/pass.scd
M files/scripts/i3blocks/i3blocks-yubikey
M files/scripts/shell/Makefile
D files/scripts/shell/pass
M files/docs/shell/Makefile => files/docs/shell/Makefile +0 -1
@@ 31,7 31,6 @@ shell-docs:
	setup/setup-doc shell/night-mode
	setup/setup-doc shell/notify
	setup/setup-doc shell/open-document
	setup/setup-doc shell/pass
	setup/setup-doc shell/pick-task
	setup/setup-doc shell/play-somafm
	setup/setup-doc shell/pomodoro

D files/docs/shell/pass.scd => files/docs/shell/pass.scd +0 -42
@@ 1,42 0,0 @@
PASS(1perso)

# NAME

pass - Wrapper for *pass*(1)

# SYNOPSIS

see *pass*(1)

# DESCRIPTION

Pass wrapper for Yubikey PGP touch notifications.

Only supports the exact commands used internally using the "show" subcommand.

# OPTIONS

No change

# OPERANDS

*touch*
	Display pass names waiting for a touch if any++
_WARNING_: the names are in the order they were added but this does not mean
they would be decrypted in that same order after the touch.

# ENVIRONMENT VARIABLES

_XDG_RUNTIME_DIR_
	Path to user-specific base directory to store runtime files++
If unset, defaults to /tmp

# FILES

_$XDG_RUNTIME_DIR/yubikey_gpg_
	Contains information about the pass names waiting for a touch

# DEPENDENCIES

- mktemp
- pkill

M files/scripts/i3blocks/i3blocks-yubikey => files/scripts/i3blocks/i3blocks-yubikey +2 -13
@@ 1,27 1,16 @@
#!/bin/sh
# commands used:
# - i3blocks-mode
# - pass (wrapper)
# - ykman (wrapper)

MODE="$( i3blocks-mode )"

OATH_TOUCH_STATUS="$( ykman oath touch )"
PGP_TOUCH_STATUS="$( pass touch )"

# it's currently not possible for both OATH and PGP to be waiting for touch
if [ "${OATH_TOUCH_STATUS}" = 'not waiting' ]; then
  if [ "${PGP_TOUCH_STATUS}" = 'not waiting' ]; then
    exit 0
  else
    TOUCH_STATUS="PGP: $( echo "${PGP_TOUCH_STATUS}" | paste -sd, )"
  fi
else
  TOUCH_STATUS="OATH: ${OATH_TOUCH_STATUS}"
fi
[ "${OATH_TOUCH_STATUS}" = 'not waiting' ] && exit 0

if [ "${MODE}" = 'full' ]; then
  TEXT=" ${TOUCH_STATUS}"
  TEXT=" ${OATH_TOUCH_STATUS}"
else
  TEXT=''
fi

M files/scripts/shell/Makefile => files/scripts/shell/Makefile +0 -1
@@ 31,7 31,6 @@ shell-scripts:
	setup/setup-script shell/night-mode
	setup/setup-script shell/notify
	setup/setup-script shell/open-document
	setup/setup-script shell/pass
	setup/setup-script shell/pick-task
	setup/setup-script shell/play-somafm
	setup/setup-script shell/pomodoro

D files/scripts/shell/pass => files/scripts/shell/pass +0 -55
@@ 1,55 0,0 @@
#!/bin/sh

PGP_FILE_PATH="${XDG_RUNTIME_DIR:-/tmp}/yubikey_pgp"

TMP_FILE="$( mktemp )"
trap 'rm -f "${TMP_FILE}"' EXIT

PGP_CODE_NAME=

start_pgp_touch() {
  echo "${PGP_CODE_NAME}" >> "${PGP_FILE_PATH}" \
    && update_i3blocks
}

end_pgp_touch() {
  # remove only one occurence of the pass name
  PGP_CODE_NAME_ESC="$( echo "${PGP_CODE_NAME}" | sed 's#/#\\/#g' )"
  awk "!/${PGP_CODE_NAME_ESC}/ || f++" "${PGP_FILE_PATH}" > "${TMP_FILE}" \
    && cp "${TMP_FILE}" "${PGP_FILE_PATH}" \
    && update_i3blocks
}

status_pgp_touch() {
  if ! [ -f "${PGP_FILE_PATH}" ] || ! [ -s "${PGP_FILE_PATH}" ] ; then
    echo 'not waiting'
  else
    cat "${PGP_FILE_PATH}"
  fi
}

update_i3blocks() {
  pkill -x -RTMIN+10 i3blocks
}

case "$@" in
  touch)
    status_pgp_touch
    exit
    ;;
  show\ -c\ *)
    PGP_CODE_NAME="$3"
    ;;
  show\ *)
    PGP_CODE_NAME="$2"
    ;;
  edit\ *)
    PGP_CODE_NAME="$2"
    ;;
esac

[ -n "${PGP_CODE_NAME}" ] && start_pgp_touch

/usr/bin/pass "$@"

[ -n "${PGP_CODE_NAME}" ] && end_pgp_touch