#!/bin/bash
## RJP 13.7.2023
## 19.1.2024 modified for non x-terminal-emulator systems
## 4.7.2026 better dialogs

TEXTDOMAINDIR=/usr/share/locale
TEXTDOMAIN=simple-search

touch ~/.Xresources
echo ' ! Use a truetype font and size.
xterm*faceName: Monospace ' | grep -xFv -f $HOME/.Xresources >> $HOME/.Xresources
echo 'xterm*faceSize: 14 ' | grep -xFv -f $HOME/.Xresources >> $HOME/.Xresources
xrdb -merge ~/.Xresources


SEARCH=`yad --center --width=500 --height=100 --text-align=center --button=OK:0 --title=$"Simple search" --text=$"The word for searching" --entry --entry-label=$"here" --entry-text=""`
PLACE=`yad --file --title=$"Select directory" --text=$"Select directory" --directory --width=1000`
if [ $? = 0 ];
then
xterm -e /bin/bash -c "cd $PLACE && find -iname '*$SEARCH*' > /tmp/result.txt && pluma /tmp/result.txt" && \
sleep 5
rm /tmp/result.txt     
else exit 0
fi
