-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecoll_query.sh
executable file
·59 lines (47 loc) · 1.45 KB
/
recoll_query.sh
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
# Query recoll index database and return in rofi dmenu mode
# dev version:
#recoll -t -N -F filename -q 'river' 2>&1 | sed -n '4,10p' | awk -F' ' '{print $2}' | xargs -n1 -I % sh -c 'echo % | base64 -d; echo '
PDFVIEWER='evince'
QUERY=$(rofi -config ~/.config/rofi/config_oneliner -lines 0 -dmenu -p \
'Recoll search. Type in the word to query:')
# Arrays
declare -a ARR_URL
declare -a ARR_FILENAME
declare -a ARR_ABS
if [[ "$QUERY" = '' ]]; then
exit
fi
~/recoll/bin/recoll -t -F 'url filename abstract' -q "$QUERY" 2>&1 | \
sed -n '4,$p' | \
# has to put everything below inside {}
{
while IFS=" " read c1 c2 c3;do
# Decode base64 and append to arrays
ARR_URL+=("$(echo $c1 | base64 -d)")
ARR_FILENAME+=("$(echo $c2 | base64 -d)")
ARR_ABS+=("$(echo $c3 | base64 -d)")
done
# Compose rofi string
ROFI_STR=""
for i in ${!ARR_URL[*]}; do
# Separate entries using "|"
strii="$(echo -e "${ARR_FILENAME[$i]}\n ${ARR_ABS[$i]} |" | \
sed 's/\.\.\./\n /g')"
ROFI_STR+="$strii"
done
echo "$ROIF_STR"
# Get user select idx(s), remove leading "-" with sed
choice_idx=($(echo -e "$ROFI_STR" | \
rofi click-to-exit false -dmenu -multi-select -format -i -eh 8 -sep '|' -config ~/.config/rofi/config_recoll -lines 6 | \
sed 's/^-//g'))
#echo "${choice_idx[*]}"
#echo "${#choice_idx[@]}"
for i in ${!choice_idx[*]}; do
cii=${choice_idx[$i]}
if [[ ! $cii = '' ]]; then
choice_url="${ARR_URL[$cii]}"
#echo "$choice_url"
$PDFVIEWER "$choice_url" &
fi
done
}