blob: dc9371b3afaa2fdea13bfcba8b0d46be6613f256 (
plain) (
blame)
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
|
#!/usr/bin/env bash
set -euo pipefail
ADD_TAG="need review"
add() {
if [[ $1 =~ (https|ftp|file):// ]]; then
index=$(buku --nostdin --json --add "$1" | jq .index)
if [ -n "$index" ]; then
buku -u "$index" --tag + "$ADD_TAG"
fi
return 0
fi
return 1
}
main() {
local url
if [ $# -eq 0 ]; then
url="$(xsel -ob)"
else
url="$1"
fi
if add "$url"; then
alert "URL added: $url"
else
alert "URL error: $url"
fi
}
main "$@"
|