blob: 144a9d9bd5fdaaa06a8b9028c8d45515e5e9ad4d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
#!/bin/sh
#
# BOOKMARK
#
bookmarks="$HOME/documents/bookmarks.csv"
browser=librewolf
# Add a bookmark
add_bookmark() {
# Get URL from browser
wlrctl window focus $browser || exit 1
wtype -M ctrl l -m ctrl
wtype -M ctrl c -m ctrl
sleep 0.5
url=$(wl-paste --primary)
# Check if bookmark exists
if grep "$url" "$bookmarks"; then
notify-send "Bookmark already exists!"
exit 1
fi
# Prompt for url confirmation
addbookmark=$(printf "Yes\nNo" | bemenu -p "Add '$url' to bookmarks?" --auto-select)
# Description
if [ "$addbookmark" = "Yes" ]; then
title=$(: | bemenu -p "Enter a description: ")
[ -z "$title" ] && exit 1
tag=$(: | bemenu -p "Enter a tag: ")
[ -z "$title" ] && exit 1
printf "%s,%s,%s" "$url" "$tag" "$title" >> "$bookmarks" \
&& notify-send "Bookmark Added" "$url"
fi
}
case "$(printf 'Open\nWatch\nListen\nCopy\nType\nAdd' | bemenu -p 'Bookmark action')" in
"Open")
title=$(cut -f3 -d, "$bookmarks" | sed -E 's/^\s+//' | bemenu -p 'Select Bookmark')
[ -z "$title" ] && exit 1
url=$(grep "$title" "$bookmarks" | cut -f1 -d, | sed -E 's/^\s//')
[ -z "$url" ] && exit 1
wlrctl window focus $browser
$browser "$url"
;;
"Watch")
title=$(grep "\bvideo\b\|\bmusic\b" "$bookmarks" | cut -f3 -d, | bemenu -p 'Select Bookmark')
url=$(grep "$title" "$bookmarks" | cut -f1 -d,)
[ -z "$url" ] && exit 1
mpv "$url"
;;
"Listen")
title=$(grep "\bmusic\b" "$bookmarks" | cut -f3 -d, | sed 's/^ //g' | bemenu -p 'Select Bookmark')
url=$(grep "$title" "$bookmarks" | cut -f1 -d, | sed 's/^ //g')
[ -z "$url" ] && exit 1
footclient mpv --no-video "$url"
;;
"Copy")
url=$(cut -f1 -d, "$bookmarks" | bemenu -p 'Select Bookmark')
[ -z "$url" ] && exit 1
wl-copy -on "$url"
notify-send "Copied" "$url"
;;
"Type")
url=$(cut -f1 -d, "$bookmarks" | bemenu -p 'Select Bookmark')
[ -z "$url" ] && exit 1
echo "$url" | wtype -
;;
"Add")
add_bookmark
;;
*)
exit 1
;;
esac
|