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

View file

@ -1,15 +1,16 @@
# Beware! This file is rewritten by htop when settings are changed in the interface.
# The parser is also very primitive, and not human-friendly.
htop_version=3.2.1
config_reader_min_version=3
fields=0 48 17 18 38 39 40 2 46 47 49 1
sort_key=46
sort_direction=-1
tree_sort_key=47
tree_sort_direction=-1
hide_kernel_threads=1
hide_userland_threads=0
shadow_other_users=1
show_thread_names=0
show_program_path=1
highlight_base_name=1
highlight_deleted_exe=1
highlight_megabytes=1
highlight_threads=1
highlight_changes=0
@ -17,8 +18,9 @@ highlight_changes_delay_secs=5
find_comm_in_cmdline=1
strip_exe_from_cmdline=1
show_merged_command=1
tree_view=1
tree_view_always_by_pid=0
header_margin=1
screen_tabs=1
detailed_cpu_time=1
cpu_count_from_one=1
show_cpu_usage=1
@ -30,34 +32,8 @@ account_guest_in_cpu_meter=1
color_scheme=0
enable_mouse=1
delay=5
left_meters=AllCPUs Memory Swap
left_meter_modes=1 1 1
right_meters=Tasks LoadAverage Uptime
right_meter_modes=2 2 2
hide_function_bar=0
header_layout=three_25_25_50
column_meters_0=CPU Memory Swap ZFSARC ZFSCARC
column_meter_modes_0=1 1 1 2 2
column_meters_1=DiskIO NetworkIO LoadAverage Tasks Battery
column_meter_modes_1=1 1 1 1 1
column_meters_2=PressureStallIOFull PressureStallMemoryFull Hostname DateTime Uptime
column_meter_modes_2=1 1 2 2 2
tree_view=1
sort_key=46
tree_sort_key=47
sort_direction=-1
tree_sort_direction=1
tree_view_always_by_pid=0
all_branches_collapsed=0
screen:Main=PID USER PRIORITY NICE M_VIRT M_RESIDENT M_SHARE STATE PERCENT_CPU PERCENT_MEM TIME Command
.sort_key=PERCENT_CPU
.tree_sort_key=PERCENT_MEM
.tree_view=1
.tree_view_always_by_pid=0
.sort_direction=-1
.tree_sort_direction=1
.all_branches_collapsed=0
screen:I/O=PID USER IO_PRIORITY IO_RATE IO_READ_RATE IO_WRITE_RATE
.sort_key=IO_RATE
.tree_sort_key=PID
.tree_view=0
.tree_view_always_by_pid=0
.sort_direction=-1
.tree_sort_direction=1
.all_branches_collapsed=0

View file

@ -1,5 +1,17 @@
# Documentation is available online at https://www.gnupg.org/documentation/manuals/gnupg/GPG-Configuration-Options.html#gpg_002doption-_002d_002doptions
# Make sure to use my new PGP key instead of the old one.
# TODO: Schedule key expiration for the old one soonish.
default-key 4D5E631758CB9CC45941B1CE67BFC91B3DA12BE8
# Go abit like Keybase, but keep the WoT parts.
trust-model tofu+pgp
# use keys.openpgp.org instead of keyserver.ubuntu.com or whatever
keyserver hkps://keys.openpgp.org
# long fpr + 0x prefix
keyid-format 0xlong
# From the docs: This is dummy option. gpg always requires the agent.
#use-agent

12
.gnupg/gpg-agent.conf Normal file
View file

@ -0,0 +1,12 @@
# Cache passphrases for 15m by default up to 3 hours.
default-cache-ttl 900
max-cache-ttl 10800
default-cache-ttl-ssh 900
max-cache-ttl-ssh 10800
# Let's be serious about our password hygenine
min-passphrase-len 12
min-passphrase-nonalpha 3
# Use our bloody pinentry handler for that.
pinentry-program ~/bin/handle-pinentry

5
.vscode/extensions.json vendored Normal file
View file

@ -0,0 +1,5 @@
{
"recommendations": [
"mads-hartmann.bash-ide-vscode"
]
}

17
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,17 @@
{
"git.alwaysSignOff": true,
"gitlens.remotes": [
{
"domain": "mau.dev",
"type": "GitLab"
},
{
"domain": "tildegit.com",
"type": "Gitea"
},
{
"domain": "git.vern.cc",
"type": "Gitea"
}
]
}

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}"