From 01cac0167f09867cbaf7656702acd45b817e9752 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Thu, 28 Oct 2021 11:41:53 +0200 Subject: [PATCH] [scripts] feat: improve dmenuopen speed don't look into every folder in $HOME filter using `find`, not `grep` --- .local/bin/dmenuopen | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.local/bin/dmenuopen b/.local/bin/dmenuopen index 9ac96a1..531d7bb 100755 --- a/.local/bin/dmenuopen +++ b/.local/bin/dmenuopen @@ -10,22 +10,22 @@ ###################################################################### -filetypes=".pdf .png .jpg .txt .mom .tex .mkv" # could be augmented +filetypes="pdf png jpg txt mom tex mkv" # could be augmented filetype=$(printf "$filetypes" | sed "s| |\n|g" | dmenu -i -p "type of the file?") if [ -z "$filetype" ]; then exit 0 fi -file=$(find $HOME/ -type f | grep "$filetype" | dmenu -i -l 20 -p "open") +file=$(find $HOME/{documents,downloads} -type f -path "*.$filetype" | dmenu -i -l 20 -p "open") if [ -z "$file" ]; then exit 0 fi case "$filetype" in - *.pdf) zathura "$file" ;; - *.png|.jpg) sxiv "$file" ;; - *.txt|*.mom|*.tex) "$TERMINAL" -e nvim "$file" ;; - *.mkv) mpv "$file";; + pdf) zathura "$file" ;; + png|jpg) sxiv "$file" ;; + txt|mom|tex) "$TERMINAL" -e nvim "$file" ;; + mkv) mpv "$file";; esac