-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile-handler
executable file
·36 lines (34 loc) · 950 Bytes
/
file-handler
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env bash
filename="$1"
filetype=$(file -b "$filename" | awk '{ print $1 }')
case "$filetype" in
"PNG" | "JPG" | "JPEG" | "GIF" | "SVG" | "ICO" | "WEBP")
feh "$filename"
;;
"MP4" | "WEBM")
mpv "$filename"
;;
"PDF")
zathura "$filename"
;;
"Microsoft")
wps "$filename"
;;
# add for "CIRC" files in logisim which show up as xml
*)
if file -b "$filename" | grep -q "script"; then
choice=$(printf "Yes\nNo" | dmenu -i -sb purple -p "Run this script ? " -nb black)
if [ $? -eq 1 ]; then
exit 0
fi
if [ "$choice" == "Yes" ]; then
"$filename"
else
kitty -e vim $filename
fi
elif file -b "$filename" | grep -q "text"; then
kitty -e vim "$filename"
else
kitty -e "$filename"
fi
esac