-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathpdfgrep-gui
More file actions
executable file
·76 lines (61 loc) · 1.99 KB
/
Copy pathpdfgrep-gui
File metadata and controls
executable file
·76 lines (61 loc) · 1.99 KB
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
#!/bin/bash
function open_uri () {
xdg-open "$3"
}
export -f open_uri
start_pattern=$1
start_path=$2
[[ -z $1 ]] && start_pattern=""
[[ -z $2 ]] && start_path=$HOME
values=$(yad \
--form \
--field=Keyword \
"$start_pattern" \
--field=Path:DIR \
"$start_path" \
--class="Keyword-And-Path" \
--name="Keyword and Path" \
--title="$(basename "$0") - Keyword and Path" \
--center \
--width=400 \
--separator="~/~" \
)
pattern=$(echo "$values" | awk -F "~/~" '{print $1}')
[[ -z "$pattern" ]] && exit 1
path=$(echo "$values" | awk -F "~/~" '{print $2}')
[[ -z "$path" ]] && exit 1
#exec 4> >(yad --progress --auto-close --pulsate --undecorated --no-buttons --center)
exec 3> >(yad \
--center \
--class="Search-Results" \
--name="Search Results" \
--text="The search term <b>\"$pattern\"</b> was found in these files. Double to open a file." \
--save \
--list \
--column="Author" \
--column="Title" \
--column="Path" \
--button="Close:1" \
--width=700 \
--height=500 \
--title="$(basename "$0") - Search Results" \
--dclick-action="bash -c \"open_uri %s &\"" \
--quoted-output \
--listen \
--separator="~/~" \
)
#exec 4> >(yad --progress --pulsate --auto-close --center)
notify-send "$(basename "$0")" "Start search for <b>$pattern</b> in <b>$path</b>"
#echo "Title A" >&3
#echo "/home/aboettger/Eisenbahn/Eisenbahnliteratur/Autorengruppe - Modelleisenbahner/Modelleisenbahner (2025)/Modelleisenbahner - Autorengruppe - Modelleisenbahner.pdf" >&3
pdfgrep -r "$pattern" "$path" 2> /dev/null | awk -F ":" '{out=$2; for(i=3;i<=NF;i++){out=out":"$i}; print $1}' | uniq | { while read -r pdf_path;
do
pdfinfo "$pdf_path" | grep "Author" | awk '{sub(/[^ ]+ /, ""); print $0}' | sed 's/^[ \t]*//;s/[ \t]*$//' >&3
pdfinfo "$pdf_path" | grep "Title" | awk '{sub(/[^ ]+ /, ""); print $0}' | sed 's/^[ \t]*//;s/[ \t]*$//' >&3
echo "$pdf_path" >&3
done
}
notify-send "$(basename "$0")" "Finished search for <b>$pattern</b> in <b>$path</b>"
exec 3>&-
#exec 4>&-
exit 0