diff --git a/Drew/git-notes-status.sh b/Drew/git-notes-status.sh new file mode 100755 index 0000000..389f920 --- /dev/null +++ b/Drew/git-notes-status.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +NOTES_DIR="$HOME/git.thelinuxcast.org/notes" + +if [ ! -d "$NOTES_DIR" ]; then + exit 0 +fi + +# Simple lock to prevent multiple simultaneous executions +LOCK_FILE="/tmp/git-notes-status.lock" +if [ -f "$LOCK_FILE" ]; then + exit 0 +fi +touch "$LOCK_FILE" +trap 'rm -f "$LOCK_FILE"' EXIT + +cd "$NOTES_DIR" || exit 0 + +# Fetch latest changes silently +git fetch origin >/dev/null 2>&1 + +# Get current branch +CURRENT_BRANCH=$(git branch --show-current 2>/dev/null) +if [ -z "$CURRENT_BRANCH" ]; then + exit 0 +fi + +# Check commits behind and ahead +BEHIND=$(git rev-list --count HEAD..origin/"$CURRENT_BRANCH" 2>/dev/null || echo "0") +AHEAD=$(git rev-list --count origin/"$CURRENT_BRANCH"..HEAD 2>/dev/null || echo "0") + +# Build status message +if [ "$AHEAD" -gt 0 ] && [ "$BEHIND" -gt 0 ]; then + notify-send "Git Notes" "$AHEAD ahead, $BEHIND behind" +elif [ "$AHEAD" -gt 0 ]; then + notify-send "Git Notes" "$AHEAD commits ahead" +elif [ "$BEHIND" -gt 0 ]; then + notify-send "Git Notes" "$BEHIND commits behind" +else + notify-send "Git Notes" "Up to date" +fi \ No newline at end of file diff --git a/Drew/rofi-notes.sh b/Drew/rofi-notes.sh new file mode 100755 index 0000000..8c47ebb --- /dev/null +++ b/Drew/rofi-notes.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +# Configuration +REPO_API_BASE="https://git.thelinuxcast.org/api/v1/repos/tlc/notes" +SHORT_URL_BASE="https://git.thelinuxcast.org/notes" + +# Function to convert full URL to short URL +convert_to_short_url() { + local file_path="$1" + echo "$SHORT_URL_BASE/$file_path" +} + +# Get list of files recursively from git API +get_file_list() { + # Get the tree recursively from main branch + curl -s "$REPO_API_BASE/git/trees/main?recursive=true" | \ + jq -r '.tree[] | select(.path | endswith(".md")) | select(.path | test("README.md") | not) | .path' | \ + sort +} + +# Detect clipboard tool and set copy function +setup_clipboard() { + if command -v wl-copy >/dev/null 2>&1; then + CLIPBOARD_CMD="wl-copy" + elif command -v xclip >/dev/null 2>&1; then + CLIPBOARD_CMD="xclip -selection clipboard" + else + echo "No clipboard tool found. Install wl-clipboard (Wayland) or xclip (X11)." + exit 1 + fi +} + +# Check if required tools are available +check_dependencies() { + local missing_deps=() + + command -v curl >/dev/null 2>&1 || missing_deps+=("curl") + command -v jq >/dev/null 2>&1 || missing_deps+=("jq") + command -v rofi >/dev/null 2>&1 || missing_deps+=("rofi") + + if [ ${#missing_deps[@]} -ne 0 ]; then + echo "Missing dependencies: ${missing_deps[*]}" + echo "Please install them first." + exit 1 + fi +} + +# Main script +check_dependencies +setup_clipboard + +selected_file=$(get_file_list | rofi -dmenu -p "Select note file:" -i) + +if [ -n "$selected_file" ]; then + # Convert to short URL + short_url=$(convert_to_short_url "$selected_file") + + # Copy to clipboard + echo "$short_url" | $CLIPBOARD_CMD + + # Optional: show notification + notify-send "URL Copied" "$short_url" + + echo "Copied to clipboard: $short_url" +fi \ No newline at end of file