adding zmenu, arching qutebrowser again cuz it crashes too much, fixed vault script

This commit is contained in:
2025-05-03 12:46:37 -07:00
parent 92a464415c
commit 95c5a519bb
12 changed files with 265 additions and 38 deletions

View File

@@ -1,50 +1,61 @@
#!/bin/sh
#!/usr/bin/env bash
# vault — mount/dismount VeraCrypt containers with automatic mountpoint creation and cleanup
# now suppresses PIM, keyfile, and hiddenvolume prompts by default
# Usage: vault {open|close} /full/path/to/container.hc
CONTAINER=${2:-"$HOME/vault.hc"}
set -euo pipefail
BASENAME=$(basename "$CONTAINER")
MAPPER_NAME="${BASENAME%.*}"
MOUNT_POINT="/mnt/$MAPPER_NAME"
usage() {
echo "Usage: $0 {open|close} /full/path/to/container.hc"
exit 1
}
case "$1" in
[[ $# -eq 2 ]] || usage
action=$1
rawpath=$2
container=$(eval echo "$rawpath")
[[ -f "$container" ]] || { echo "Container not found: $container"; exit 1; }
# derive mountpoint
base=$(basename "$container")
name="${base%.*}"
mountpoint="/mnt/$name"
require_sudo() {
if (( EUID != 0 )); then
exec sudo bash "$0" "$action" "$rawpath"
fi
}
case "$action" in
open)
if [ ! -f "$CONTAINER" ]; then
echo "Container not found: $CONTAINER"
exit 1
if mountpoint -q "$mountpoint"; then
echo "Already mounted at $mountpoint"
exit 0
fi
if [ -e "/dev/mapper/$MAPPER_NAME" ]; then
echo "Already opened at /dev/mapper/$MAPPER_NAME"
exit 1
fi
mkdir -p "$MOUNT_POINT" || exit 1
if sudo cryptsetup open --type tcrypt "$CONTAINER" "$MAPPER_NAME"; then
sudo mount "/dev/mapper/$MAPPER_NAME" "$MOUNT_POINT" &&
echo "Mounted at $MOUNT_POINT"
else
echo "Failed to open container."
exit 1
fi
require_sudo
mkdir -p "$mountpoint"
veracrypt -t \
--keyfiles="" \
--pim=0 \
--protect-hidden=no \
--mount "$container" "$mountpoint"
echo "Mounted $container → $mountpoint"
;;
close)
if mountpoint -q "$MOUNT_POINT"; then
sudo umount "$MOUNT_POINT"
fi
if [ -e "/dev/mapper/$MAPPER_NAME" ]; then
sudo cryptsetup close "$MAPPER_NAME"
echo "Closed and unmounted $MOUNT_POINT."
else
echo "Container is not open."
require_sudo
# dismount and suppress warnings
veracrypt -t --dismount "$mountpoint" || true
# cleanup empty dir
if [[ -d "$mountpoint" ]]; then
rmdir "$mountpoint" && echo "Removed mountpoint $mountpoint"
fi
;;
*)
echo "Usage: $0 {open|close} [path/to/container.hc]"
exit 1
usage
;;
esac