diff options
Diffstat (limited to 'example')
| -rwxr-xr-x | example/opener_ext | 27 | ||||
| -rwxr-xr-x | example/opener_mime | 33 |
2 files changed, 60 insertions, 0 deletions
diff --git a/example/opener_ext b/example/opener_ext new file mode 100755 index 0000000..ce1699a --- /dev/null +++ b/example/opener_ext @@ -0,0 +1,27 @@ +#!/bin/sh -feu +# +# Example DFM_OPENER script using file extension. +# + +case $1 in + *.mkv | *.webm | *.mp4 | *.avi) + exec mpv -- "$1" + ;; + + *.opus | *.mp3 | *.wav | *.flac | *.ogg) + exec mus --no-shuffle -- "$1" + ;; + + *.jpg | *.jpeg | *.gif | *.png | *.CR2) + exec mpv --pause -- "$1" + ;; + + *.svg) + exec inkscape "$1" + ;; + + *?*) + exec "${EDITOR:-vim}" "$1" + ;; +esac + diff --git a/example/opener_mime b/example/opener_mime new file mode 100755 index 0000000..2f7bd52 --- /dev/null +++ b/example/opener_mime @@ -0,0 +1,33 @@ +#!/bin/sh -feu +# +# Example DFM_OPENER script using mimetype. +# + +mime_type=$(file -bi "$1") + +case $mime_type in + audio/*) + exec mpv --no-video "$1" + ;; + + video/*) + exec mpv "$1" + ;; + + image/*) + exec gimp "$1" + ;; + + text/html* | application/pdf*) + exec firefox "$1" + ;; + + text/*) + exec "${EDITOR:=vi}" "$1" + ;; + + *?*) + printf 'error: unhandled mime-type %s\n' "$mime_type" >&2 + ;; +esac + |