diff options
| author | Lukasz Kasprzak <lukasz.kasprzak@pm.me> | 2026-04-14 22:32:43 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukasz.kasprzak@pm.me> | 2026-04-14 22:32:43 +0200 |
| commit | 83f7fe4b8402bab171d110703a1b1115efbc9b28 (patch) | |
| tree | 19110702c7d740f6bd8ee4f5d2ebcb97442be237 /bookmark-clip | |
| parent | 51d43498b07dc97d795947964534f0903cd05db5 (diff) | |
| download | bin-83f7fe4b8402bab171d110703a1b1115efbc9b28.tar.gz bin-83f7fe4b8402bab171d110703a1b1115efbc9b28.zip | |
cleaned up many scrits and deleted some that were of no use; renamed a lot
Diffstat (limited to 'bookmark-clip')
| -rwxr-xr-x | bookmark-clip | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/bookmark-clip b/bookmark-clip new file mode 100755 index 0000000..57b14c7 --- /dev/null +++ b/bookmark-clip @@ -0,0 +1,37 @@ +#!/bin/sh +set -eu + +file="$HOME/.bookmarks" +touch "$file" + +has_notify=$(command -v notify-send >/dev/null 2>&1 && echo 1 || echo 0) +notify() { [ "$has_notify" = 1 ] && notify-send -u "$1" "bookmark" "$2" || true; } + +# Primary selection first, fall back to clipboard +bookmark="$(xclip -o -selection primary 2>/dev/null || true)" +[ -z "$bookmark" ] && bookmark="$(xclip -o -selection clipboard 2>/dev/null || true)" + +bookmark="$(printf '%s' "$bookmark" | sed 's/[[:space:]]\+$//')" + +if [ -z "$bookmark" ]; then + notify critical "Nothing selected or in clipboard" + exit 1 +fi + +if awk -F'\t' '{print $1}' "$file" | grep -Fxq -- "$bookmark"; then + notify low "Already bookmarked" + exit 0 +fi + +bookmarkEdit="$(printf '%s' "$bookmark" | dmenu -p "Edit bookmark:")" +out="${bookmarkEdit:-$bookmark}" + +comment="$(printf '' | dmenu -p "Add comment (optional):")" +if [ -n "${comment:-}" ]; then + line="$(printf '%s\t# %s' "$out" "$comment")" +else + line="$out" +fi + +printf '%s\n' "$line" >> "$file" +notify normal "Saved: $out" |
