2022-05-31 23:01:54 +00:00
|
|
|
#!/bin/sh -e
|
|
|
|
# Use xdg-mime with a file's mime type
|
2022-08-28 20:36:34 +00:00
|
|
|
# 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" &&
|
2022-05-31 23:01:54 +00:00
|
|
|
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
|
2022-05-31 23:01:54 +00:00
|
|
|
# || echo "Cannot find application $2 in /usr/share/applications!"
|