Iron out gpg and gpg-agent config, among other things

Also in this commit:
* Added handle-pinentry wrapper script to exec right pinentry
  based on environment.
* Add VS Code config for stuff like GitLens settings and recommended
  extensions.

Signed-off-by: Andrei Jiroh Halili <ajhalili2006@andreijiroh.eu.org>
This commit is contained in:
Andrei Jiroh Halili 2023-07-25 02:11:50 +08:00
parent 9fe9c3b3f2
commit 847b847c79
No known key found for this signature in database
GPG key ID: 67BFC91B3DA12BE8
7 changed files with 114 additions and 35 deletions

54
bin/handle-pinentry Normal file
View file

@ -0,0 +1,54 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: MIT AND MPL-2.0
# This is bit chaotic at best, per https://unix.stackexchange.com/a/116694.
# Maybe we should aggressively detect more desktop environments, even non-DEs
# as per https://askubuntu.com/a/227669.
set -e
if [[ $DEBUG != "" ]]; then
set -x
fi
GPG_TTY=$(tty)
error() {
echo "error: $*"
}
warn() {
echo "warn: $*"
}
detect_env() {
if [ "$XDG_CURRENT_DESKTOP" = "" ]
then
desktop=$(echo "$XDG_DATA_DIRS" | sed 's/.*\(xfce\|kde\|gnome\).*/\1/')
else
desktop=$XDG_CURRENT_DESKTOP
fi
desktop=${desktop,,} # convert to lower case
}
path_detection() {
if [[ $desktop == "kde" ]]; then
if command -v pinentry-qt >> /dev/null; then
target_bin=pinentry-qt
else
error "pinentry-qt isn't installed on your system or not found on PATH"
exit 1
fi
else
warn "environment can't be detected ($desktop), using pinentry-curses"
if command -v pinentry-curses >> /dev/null; then
target_bin=pinentry-curses
else
error "pinentry-curses isn't installed on your system or not found on PATH"
exit 1
fi
fi
}
detect_env
path_detection
export GPG_TTY
exec $target_bin "$@"

View file

@ -1,4 +1,7 @@
#!/usr/bin/bash
# SPDX-License-Identifier: MPL-2.0
# A mini scirpt to handle chrooting into different environments,
# especially for Alpine Linux devenv on chroots instead of containers/VMs.
# Chroot command is optional and assume login binary
CHROOT_COMMAND=${2:-"/usr/bin/login"}
@ -33,4 +36,4 @@ fi
echo "===> Teleporting to the chroot environment in 3 seconds..."
sleep 3
exec chroot "$TARGET_DIR" ${CHROOT_COMMAND}
exec chroot "$TARGET_DIR" "${CHROOT_COMMAND}"