1

I am using a bash script to provide a search utlilty to locate and open files and directories.

here is the script:

#!/bin/bash
lxterminal -e "bicon.bin locate /home /run/media |fzf >| ~/.mylocateData"
              # ^ this the problematic part
sleep 0.4
while [[ "$(pidof fzf)" != "" ]] ; do
    sleep 0.4
done
file="$(cat ~/.mylocateData)"
if [[ -z "$file" ]] ; then exit ; fi
mimetype=$(file  --dereference --brief --mime-type  "$file" )
case "$mimetype" in
      inode/directory)            lxterminal -e bicon.bin ranger "$file" ;;
      image/*)                    feh "$file" & disown ;;
      text/* | */xml)             lxterminal -e vim "$file"  ;;
      video/* | audio/*)          mpv --really-quiet --loop "$file" & disown ;;
     application/pdf)             okular "$file" & disown ;;
     application/octet-stream)
                                 if [[ "${file#*.}" == "MP3" ]]
                                    then
                                         mpv --really-quiet --loop "$file" & disown
                                 fi
                                 ;;
     *)                            lxterminal -e bicon.bin ranger --selectfile="$file" ;;
esac

if I run the first command with bicon.bin included the text of fzf handles the arabic filenames as expected, however the file name saved in .mylocateData file is somehow corrupted and I cannot open it. I tried some debuuging like ls "$(cat .mylocateData) to confirm.

but if I run my script without bicon.bin fzf shows the search but with arabic characters from left to right (in an ugly way ) but the file name is correctly saved regardless and it can be opened.

MY QUESTION is : how can I achieve both goals ? if it is a matter of reading the file some way other than cat ? or is it the use of fzf?

PS : I'm not interested in using dmenu, rofi ...etc, I love the way fzf works and I want to use it in my arch i3wm desktop

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.