diff options
| author | David T. Sadler <davidtsadler@googlemail.com> | 2026-06-21 19:17:44 +0100 |
|---|---|---|
| committer | David T. Sadler <davidtsadler@googlemail.com> | 2026-06-21 19:17:44 +0100 |
| commit | 63c8dad6d9da57bd9c8cfa19f9fdce99f3533d9e (patch) | |
| tree | c593d8a8724b6f59bed9d40ab1ae4ee2d7c0ef80 /bin/.bin | |
| parent | 1d6ba877af1ecf2e2bc87b3eca1c2e5cb87dd97d (diff) | |
| parent | aebda32c2a09fcbdc1e645f55a0c6de3b9a2cfaf (diff) | |
Merge branch 'main' into howl
Diffstat (limited to 'bin/.bin')
| -rwxr-xr-x | bin/.bin/add-bookmark.sh | 36 | ||||
| -rwxr-xr-x | bin/.bin/new-episode | 35 | ||||
| -rwxr-xr-x | bin/.bin/open-bookmark.sh | 23 |
3 files changed, 59 insertions, 35 deletions
diff --git a/bin/.bin/add-bookmark.sh b/bin/.bin/add-bookmark.sh new file mode 100755 index 0000000..9a8ab6b --- /dev/null +++ b/bin/.bin/add-bookmark.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +set -euo pipefail + +BOOKMARKS_FILE="$DOTFILES_REPO/bookmarks.txt" + +mkdir -p "$(dirname "$BOOKMARKS_FILE")" +touch "$BOOKMARKS_FILE" + +xdotool key --delay 50 ctrl+l ctrl+c Escape + +sleep 0.15 + +URL=$(xclip -selection clipboard -o) + +if [[ "$URL" =~ ^https?:// ]]; then + NAME=$(zenity --entry \ + --title="Add Bookmark" \ + --text="Enter a name for this bookmark:" \ + --entry-text="" 2>/dev/null) + + if [ -z "$NAME" ]; then + notify-send "Bookmark Cancelled" "No name was provided." + exit 0 + fi + + CLEAN_NAME=$(echo "$NAME" | tr '|' '-') + + if ! grep -q "|$URL$" "$BOOKMARKS_FILE"; then + echo "$CLEAN_NAME|$URL" >>"$BOOKMARKS_FILE" + notify-send "Bookmark Saved" "$CLEAN_NAME\n$URL" + else + notify-send "Bookmark" "This exact URL already exists!" + fi +else + notify-send "Bookmark Error" "Clipboard did not contain a valid URL." +fi diff --git a/bin/.bin/new-episode b/bin/.bin/new-episode deleted file mode 100755 index c8a2305..0000000 --- a/bin/.bin/new-episode +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash - -if [ -z "$1" ]; then - echo "Usage: new-episode <number> <name>" - exit 1 -fi - -EP_NUM=$(printf "%03d" "$1") - -# Capture the Name (Shift the first arg so we can join the rest). -shift -RAW_NAME="${*:-untitled}" - -# Create the Title (Capitalize first letter of every word). -# Using a simple sed regex to capitalize words. -EP_TITLE=$(echo "$RAW_NAME" | sed 's/\b./\U&/g') - -# Create the Filename Slug (Lower case and replace spaces with hyphens) -# tr '[:upper:]' '[:lower:]' handles the casing -# tr ' ' '-' handles the spaces -SLUG=$(echo "$RAW_NAME" | tr '[:upper:]' '[:lower:]' | tr ' ' '-') -FILENAME="episode-${EP_NUM}-${SLUG}.php" - -# Generate the file -cat <<EOF > "$FILENAME" -<?php - -declare(strict_types=1); - -/** - * Episode ${EP_NUM}: ${EP_TITLE} - * The Coding Brummie Fundamental PHP Series - */ - -EOF diff --git a/bin/.bin/open-bookmark.sh b/bin/.bin/open-bookmark.sh new file mode 100755 index 0000000..67e724b --- /dev/null +++ b/bin/.bin/open-bookmark.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -euo pipefail + +BOOKMARKS_FILE="$DOTFILES_REPO/bookmarks.txt" + +if [ ! -f "$BOOKMARKS_FILE" ] || [ ! -s "$BOOKMARKS_FILE" ]; then + notify-send "Bookmarks" "Your bookmarks file is empty or missing." + exit 1 +fi + +SELECTION=$(cut -d'|' -f1 "$BOOKMARKS_FILE" | rofi -dmenu -p "Go To:") + +if [ -z "$SELECTION" ]; then + exit 0 +fi + +URL=$(grep "^$SELECTION|" "$BOOKMARKS_FILE" | head -n 1 | cut -d'|' -f2) + +if [ -n "$URL" ]; then + firefox "$URL" & +else + notify-send "Error" "Could not resolve the URL for: $SELECTION" +fi |
