This repository has been archived on 2023-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/.local/bin/dmenuopen

32 lines
820 B
Plaintext
Raw Normal View History

#!/usr/bin/env sh
######################################################################
2020-05-23 15:47:21 +02:00
# @author : swytch
# @file : dmenuopen
# @license : MIT
2020-05-23 15:47:21 +02:00
# @created : Wednesday May 20, 2020 18:08:05 CEST
#
2020-05-23 15:47:21 +02:00
# @description : find a file, open it with appropriate application
######################################################################
2020-05-06 03:20:19 +02:00
filetypes=".pdf .png .jpg .txt .mom .tex .mkv" # could be augmented
2020-05-06 03:46:37 +02:00
filetype=$(printf "$filetypes" | sed "s| |\n|g" | dmenu -i -p "type of the file?")
2020-05-06 03:20:19 +02:00
if [ -z "$filetype" ]; then
exit 0
fi
file=$(find $HOME/ -type f | grep "$filetype" | dmenu -i -l 20 -p "open")
if [ -z "$file" ]; then
exit 0
fi
case "$filetype" in
*.pdf) zathura "$file" ;;
2020-05-06 03:46:37 +02:00
*.png|.jpg) sxiv "$file" ;;
2020-05-06 03:20:19 +02:00
*.txt|*.mom|*.tex) "$TERMINAL" -e nvim "$file" ;;
*.mkv) mpv "$file";;
esac