mirror of
https://github.com/CoolnsX/repos_scripts.git
synced 2025-12-20 07:15:20 +05:30
29 lines
950 B
Bash
Executable File
29 lines
950 B
Bash
Executable File
#!/bin/sh
|
|
|
|
#script for bookmarking selected items and later using it..
|
|
|
|
data="$(wl-paste -p | tr '\n' '\`')"
|
|
|
|
file="$HOME/.cache/bookmarks"
|
|
|
|
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 5 "$(sed '/^$/d' "$file" | 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"
|