#!/bin/sh cachedir="${XDG_CACHE_HOME:-$HOME/.cache}/mimewiz" types="`grep -v '#'`"<< TYPES application audio font #example image #message #model #multipart text video TYPES typesrc="https://www.iana.org/assignments/media-types" #dlcsv() { curl -sS -C - -e "$typesrc" "$typesrc" > "$typefile" || exit; } dlcsv() { curl -sS -C - -o "$2" "$1" || exit; } # Download all media type csv's if they're not avaliable mkdir -p "$cachedir" for type in $types; do typefile="$cachedir/$type.csv" [ -e "$typefile" ] || dlcsv "$typesrc/$type.csv" "$typefile" #[ "$2" = "$type" ] && mimetype="`cut -d',' -f2 $typefile`" && break done #[ -n "$mimetype" ] && xdg-mime default $application.desktop $mimetype # Choose mimetype: types="$types\npdf\nspreadsheet ms-excel\nwordprocessing ms-word\npresentation ms-powerpoint\ndrawing\nzip gzip" echo "$types" | nl -s': ' echo "$types" | head -7 | tail -1 # Choose subtype #cut -d',' -f1 "$cachedir/application.csv" | grep drawing | nl -s': ' | column # Choose program ls /usr/share/applications | sed 's/\.desktop//' | nl -s': ' | column #cut -d',' -f1 "$cachedir/image.csv" | nl -s': ' | column cut -d',' -f2 "$cachedir/image.csv" #jcho "$types" | while read type; do #done