Files
repos_scripts/bkmark
2023-02-16 17:59:41 +05:30

30 lines
1.0 KiB
Bash
Executable File

#!/bin/sh
#script for bookmarking selected items and later using it..
data="$(wl-paste -p | tr '\n' '\`' | sed 's/$/ /g')"
file="$HOME/.cache/bookmarks"
oshi_file="$HOME/.cache/oshi-urls"
if [ "$*" = "add" ];then
if [ -z "$data" ];then
notify-send "Please select anything to bookmark"
elif grep -q "${data}" "$file";then
notify-send "Already bookmarked"
else
printf "%s" "$data" >> "$file"
notify-send "Bookmarked" "$data"
fi
elif [ "$*" = "rm" ];then
data="$(sed '/^$/d' "$file" | nl -n'ln')"
[ -z "$data" ] && notify-send "Bookmark is empty" && exit 0
del=$(printf "%s" "$data" | bemenu --fn 'Roboto 15' -i -c -W 0.6 -B 3 -l 30 -p "delete-bookmark :" | cut -f1)
[ -z "$del" ] || (sed -i "${del}d" "$file" && notify-send "Bookmarked deleted")
else
wtype -d 10 "$(sed '/^$/d' "$file" "$oshi_file" | sed -E 's/.*DL: ([^|]*).*/\1/g' | bemenu --fn 'Roboto 15' -i -c -W 0.6 -B 3 -l 30 -p "Put-bookmark :" | tr '\`' '\n')"
fi
sed -i '/^$/d' "$file"
printf "\n" >> "$file"