Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Script to associate .mpv.edl files with MPV (including by header)
#!/bin/sh
# Sources:
# - https://stackoverflow.com/questions/30931/register-file-extensions-mime-types-in-linux
# - https://www.freedesktop.org/wiki/Specifications/AddingMIMETutor/
echo "* Adding file-type icons..."
for SIZE in 16 32 64; do
echo "* Adding ${SIZE}px icon"
xdg-icon-resource install --context mimetypes --size "$SIZE" "/usr/share/icons/hicolor/${SIZE}x${SIZE}/apps/mpv.png" application-x-mpv-edl
done
echo "* Adding file-type definition..."
cat > edl-mime.xml << EOF
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
<mime-type type="application/x-mpv-edl">
<comment>MPV Edit Decision List</comment>
<magic priority="50">
<match type="string" value="# mpv EDL" offset="0" />
</magic>
<glob pattern="*.mpv.edl"/>
</mime-type>
</mime-info>
EOF
xdg-mime install edl-mime.xml
rm edl-mime.xml
echo "* Adding mime type association to MPV"
sed 's@\(audio/x-mpegurl;\)@\1application/x-mpv-edl;@' /usr/share/applications/mpv.desktop > ~/.local/share/applications/mpv.desktop
echo "* Updating desktop application database"
update-desktop-database ~/.local/share/applications
echo "* Updating mime type database"
update-mime-database ~/.local/share/mime
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment