#!/bin/bash
#
# gd-tools - a set of programs to enhance goldendict for immersion learning.
# Copyright (C) 2023 Ajatt-Tools
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see
'
--dicdir="$(find_dicdir)"
--userdic="${USER_DICT}"
)
if [[ -n $user_dict ]]; then
args+=("$user_dict")
fi
"${args[@]}"
}
print_css() {
cat <<-EOF
EOF
}
highlight_word() {
local target_word=$* search=""
search=$(cat -- -)
search=${search//">$target_word<"/">${target_word}<"}
echo "$search"
}
die() {
echo "$*" >&2
notify-send "$(basename -- "$0")" "$*" &
exit 1
}
main() {
if (($# == 0)) || [[ $* == --help ]] || [[ $* == -h ]]; then
usage
exit
fi
while (($# > 0)); do
case $1 in
--font-size)
shift
FONT_SIZE=$1
;;
--user-dict)
shift
USER_DICT=$1
;;
--word)
shift
GDWORD=$1
;;
--sentence)
shift
GDSEARCH=$1
;;
*)
die "Invalid argument passed."
;;
esac
shift
done
if [[ -n $USER_DICT ]] && ! [[ -f $USER_DICT ]]; then
die "Provided user dictionary doesn't exist or isn't a file."
fi
if [[ -z $GDSEARCH ]] || [[ -z $GDWORD ]]; then
die "Not enough parameters."
fi
local -r input=$(echo "$GDSEARCH" | sanitize_input)
local -r output=$(grep -Fxs -A1 "$input" -- "$TEMP_FILE")
echo '