first commit

This commit is contained in:
2025-04-17 18:00:15 -07:00
commit d4d48ef96d
35 changed files with 6842 additions and 0 deletions

32
.local/bin/bookmark_insert Executable file
View File

@@ -0,0 +1,32 @@
#!/bin/sh
bookmarks_file="$HOME/.local/share/bookmarks/bookmarks"
if [ ! -f "$bookmarks_file" ]; then
notify-send "Error" "Bookmark file doesn't exist. Please pull the repo."
echo "Bookmark file doesn't exist. Please pull the repo." >&2
exit 1
fi
# Try clipboard first, fall back to primary
clipboard_text=$(wl-paste --no-newline 2>/dev/null)
[ -z "$clipboard_text" ] && clipboard_text=$(wl-paste -p --no-newline 2>/dev/null)
# Trim leading/trailing whitespace
clipboard_text=$(echo "$clipboard_text" | xargs)
# Remove trailing slashes
clipboard_text=$(echo "$clipboard_text" | sed 's#/$##')
# Check if clipboard is not empty
if [ -n "$clipboard_text" ]; then
if grep -Fxq "$clipboard_text" "$bookmarks_file"; then
notify-send "Bookmark already exists!" "$clipboard_text"
else
echo "$clipboard_text" >> "$bookmarks_file"
notify-send "Bookmark saved" "$clipboard_text"
sh "$HOME/.local/bin/bookmark_update"
fi
else
notify-send "No text to save" "Clipboard and primary selection are empty."
fi

29
.local/bin/bookmark_update Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/sh
# Try to source keychain's environment file
if [ -f "$HOME/.keychain/$(hostname)-sh" ]; then
. "$HOME/.keychain/$(hostname)-sh"
fi
# Define the paths and repository
bookmarks_file="$HOME/.local/share/bookmarks/bookmarks"
repo_path="$HOME/.local/share/bookmarks"
# Pull the latest changes
cd "$repo_path" || exit
git pull origin master
# Check if the bookmarks file has changed
if [ -n "$(git status --porcelain "$bookmarks_file")" ]; then
# Add and commit the bookmarks file
git add "$bookmarks_file"
git commit -m "Update bookmarks file"
# Push the changes and log output
GIT_SSH_COMMAND="ssh -i ~/.ssh/ry_ecdsa" git push origin master 2>&1 | tee -a /tmp/bookmark_git_push.log
notify-send "Bookmarks updated" "Push your changes."
else
notify-send "No changes" "No changes to the bookmarks file."
fi

22
.local/bin/pass_autofill Executable file
View File

@@ -0,0 +1,22 @@
#!/bin/sh
entry=$(gopass list --flat | bemenu -p Autofill: -l 25 -c -M 500 --fn 'Monospace 14' --tf '#ff4e00' --ff '#dbc077' --hf '#ff4e00')
if [ -n "$entry" ]; then
username=$(gopass show "$entry" | grep '^username:' | cut -d' ' -f2-)
password=$(gopass show -o "$entry")
if [ -z "$password" ]; then
notify-send "Gopass Error" "No password for $entry"
exit 1
fi
notify-send "Autofill in 1s: Focus username field in form"
sleep 1
# Type username, press Tab, then password, then Enter
wtype "$username"
wtype -k Tab
wtype "$password"
wtype -k Return
fi

8
.local/bin/pass_copy Executable file
View File

@@ -0,0 +1,8 @@
#!/bin/sh
entry=$(gopass list --flat | bemenu -p Password: -l 25 -c -M 500 --fn 'Monospace 14' --tf '#ff4e00' --ff '#dbc077' --hf '#ff4e00')
if [ -n "$entry" ]; then
gopass show -c "$entry" 2>/dev/null || notify-send "Gopass Error" "Failed to copy: $entry"
fi

8
.local/bin/pass_user_copy Executable file
View File

@@ -0,0 +1,8 @@
#!/bin/sh
entry=$(gopass list --flat | bemenu -p Username: -l 25 -c -M 500 --fn 'Monospace 14' --tf '#ff4e00' --ff '#dbc077' --hf '#ff4e00')
if [ -n "$entry" ]; then
gopass show -c "$entry" username 2>/dev/null || notify-send "Gopass Error" "Failed to copy username from: $entry"
fi

47
.local/bin/todo Executable file
View File

@@ -0,0 +1,47 @@
#!/bin/sh
TODO_FILE="$HOME/docs/todo.txt"
ARCHIVE_FILE="$HOME/docs/todo-archive.txt"
TODAY="$(date +%Y-%m-%d)"
case "$1" in
add)
shift
echo "($TODAY) $*" >> "$TODO_FILE"
echo "Added: ($TODAY) $*"
;;
lsa)
nl -w2 -s'. ' "$TODO_FILE"
;;
ls)
grep -v '^x ' "$TODO_FILE" | nl -w2 -s'. '
;;
done)
if [ -z "$2" ]; then
echo "Usage: $0 done <task-number>"
exit 1
fi
TASK=$(sed -n "${2}p" "$TODO_FILE")
[ -z "$TASK" ] && { echo "Invalid task number."; exit 1; }
sed -i "${2}s/^/x ($TODAY) /" "$TODO_FILE"
echo "Marked done: $TASK"
;;
archive)
grep '^x ' "$TODO_FILE" >> "$ARCHIVE_FILE"
sed -i '/^x /d' "$TODO_FILE"
echo "Archived completed tasks to $ARCHIVE_FILE"
;;
tags)
if [ -z "$2" ]; then
echo "Usage: $0 tags <+tag|@context>"
exit 1
fi
grep "$2" "$TODO_FILE" | grep -v '^x ' | nl -w2 -s'. '
;;
help|*)
echo "Usage: $0 {add <task> | list | done <number> | archive}"
;;
esac

50
.local/bin/vault Executable file
View File

@@ -0,0 +1,50 @@
#!/bin/sh
CONTAINER=${2:-"$HOME/vault.hc"}
BASENAME=$(basename "$CONTAINER")
MAPPER_NAME="${BASENAME%.*}"
MOUNT_POINT="/mnt/$MAPPER_NAME"
case "$1" in
open)
if [ ! -f "$CONTAINER" ]; then
echo "Container not found: $CONTAINER"
exit 1
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
;;
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."
fi
;;
*)
echo "Usage: $0 {open|close} [path/to/container.hc]"
exit 1
;;
esac