dotfiles/.local/bin/scripts/xdg-mime-file

13 lines
528 B
Plaintext
Raw Normal View History

#!/bin/sh -e
# Use xdg-mime with a file's mime type
# ARGS: file [application]
2023-09-11 23:16:35 +00:00
type="$(xdg-mime query filetype "$1")"
xdg-mime query default "$type"
2022-06-27 11:03:11 +00:00
if test $# -gt 1; then
2023-09-11 23:16:35 +00:00
desktop="$(find /usr/share/applications $XDG_DATA_HOME/applications | fzf -0 -1 --query="$2" --preview 'bat --color=always --style=numbers --line-range :200 {}' | xargs -r basename)" &&
xdg-mime default "$desktop" "$type" &&
echo -n "Updated to: " &&
2023-09-11 23:16:35 +00:00
xdg-mime query default "$type"
2022-06-27 11:03:11 +00:00
fi
# || echo "Cannot find application $2 in /usr/share/applications!"