first commit
This commit is contained in:
32
.local/bin/bookmark_insert
Executable file
32
.local/bin/bookmark_insert
Executable 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
|
||||
Reference in New Issue
Block a user