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

29 lines
800 B
Plaintext
Raw Normal View History

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