occivink / mpv-image-viewer

Configuration, scripts and tips for using mpv as an image viewer
The Unlicense
284 stars 23 forks source link

Provide xdg-mime associations helper #4

Open smarek opened 5 years ago

smarek commented 5 years ago

~/.local/share/applications/mvi.desktop

#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Name=MVI
GenericName=Image Viewer
Exec=mpv --config-dir=USERHOME/.config/mvi/  %F
Terminal=false
Type=Application
Icon=image-viewer
StartupNotify=false
NoDisplay=true
Hidden=false
Categories=Graphics;Viewer;
MimeType=image/bmp;image/gif;image/jpeg;image/jpg;image/pjpg;image/png;image/tiff;image/xbmp;image/x-gray;image/x-icb;image/x-ico;image/x-icon;image/x-png;image/x-portable-anymap;image/x-portable-bitmap;image/x-portable-graymap;image/x-portable-pixmap;image/x-xpixmap;image/x-xbitmap;image/x-pcx;

And apply the MimeTypes through script-run

xdg-mime default ~/.local/share/applications/mvi.desktop (cat ~/.local/share/applications/mvi.desktop | grep MimeType | sed 's/MimeType=//' | tr ';' ' ')

Also providing install instruction in README would be useful, something along the lines

git clone --recursive https://github.com/occivink/mpv-image-viewer.git ~/.config/mvi
# be sure the path exists
mkdir -p ~/.local/share/applications/
cp ~/.config/mvi/mvi.desktop ~/.local/share/applications/
# .desktop file Exec path needs to be absolute
sed "s|USERHOME|$HOME|" ~/.local/share/applications/mvi.desktop
xdg-mime default ~/.local/share/applications/mvi.desktop (cat ~/.local/share/applications/mvi.desktop | grep MimeType | sed 's/MimeType=//' | tr ';' ' ')
update-desktop-database ~/.local/share/applications/