lots of stuff
This commit is contained in:
@@ -1,8 +1,30 @@
|
||||
#!/bin/sh
|
||||
|
||||
clipboard_text=$(wl-paste -p)
|
||||
bookmarks_file="$HOME/.local/share/bookmarks/bookmarks"
|
||||
|
||||
bookmark="$(wl-copy -o)"
|
||||
file="~/.local/share/bookmarks"
|
||||
# Make sure the bookmark file exists
|
||||
touch "$bookmarks_file"
|
||||
|
||||
# Trim leading and trailing whitespace from clipboard
|
||||
clipboard_text=$(echo "$clipboard_text" | xargs)
|
||||
|
||||
# Check if clipboard is not empty
|
||||
if [ -n "$clipboard_text" ]; then
|
||||
# Escape special characters for grep
|
||||
escaped_text=$(printf '%s\n' "$clipboard_text" | sed 's:[][\\/.^$*]:\\&:g')
|
||||
|
||||
if grep -Fxq "$escaped_text" "$bookmarks_file"; then
|
||||
# Entry already exists
|
||||
notify-send "Bookmark already exists" "$clipboard_text"
|
||||
else
|
||||
# Append the text to the bookmarks file
|
||||
echo "$clipboard_text" >> "$bookmarks_file"
|
||||
notify-send "Bookmark saved" "$clipboard_text"
|
||||
|
||||
sh "$HOME/.local/bin/bookmark_update"
|
||||
fi
|
||||
else
|
||||
notify-send "No text selected" "Please highlight some text to save as a bookmark."
|
||||
fi
|
||||
|
||||
echo "$bookmark" >> "$file"
|
||||
|
||||
24
.local/bin/bookmark_update
Executable file
24
.local/bin/bookmark_update
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
|
||||
# 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 push origin master
|
||||
|
||||
notify-send "Bookmarks updated" "Please push your changes."
|
||||
else
|
||||
notify-send "No changes" "No changes to the bookmarks file."
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user