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
David JULIEN ce6a7026d7 [scripts] fix: error codes
dmenuopen: don't return 0 in case of actual errors
switch-colors: no need to exit 0 if everything went well
2021-10-29 22:59:01 +02:00

29 lines
800 B
Bash
Executable File

#!/usr/bin/env sh
######################################################################
# @author : swytch
# @file : dmenuopen
# @license : GPLv3
# @created : Wednesday May 20, 2020 18:08:05 CEST
#
# @description : find a file, open it with appropriate application
######################################################################
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?")
[ -z "$filetype" ] && exit 1
file=$(find $HOME/{documents,downloads} -type f -path "*.$filetype" | dmenu -i -l 20 -p "open")
[ -z "$file" ] && exit 2
case "$filetype" in
pdf) zathura "$file" ;;
png|jpg) sxiv "$file" ;;
txt|mom|tex) "$TERMINAL" -e nvim "$file" ;;
mkv) mpv "$file";;
esac