[scripts] feat: improve dmenuopen speed
don't look into every folder in $HOME filter using `find`, not `grep`
This commit is contained in:
parent
d22ff7fd07
commit
01cac0167f
@ -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?")
|
filetype=$(printf "$filetypes" | sed "s| |\n|g" | dmenu -i -p "type of the file?")
|
||||||
|
|
||||||
if [ -z "$filetype" ]; then
|
if [ -z "$filetype" ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
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
|
if [ -z "$file" ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "$filetype" in
|
case "$filetype" in
|
||||||
*.pdf) zathura "$file" ;;
|
pdf) zathura "$file" ;;
|
||||||
*.png|.jpg) sxiv "$file" ;;
|
png|jpg) sxiv "$file" ;;
|
||||||
*.txt|*.mom|*.tex) "$TERMINAL" -e nvim "$file" ;;
|
txt|mom|tex) "$TERMINAL" -e nvim "$file" ;;
|
||||||
*.mkv) mpv "$file";;
|
mkv) mpv "$file";;
|
||||||
esac
|
esac
|
||||||
|
Reference in New Issue
Block a user