You are not logged in.

#1 2018-01-03 09:00:06

mipi
Member
From: Germany
Registered: 2018-01-03
Posts: 44

Where to set default application for a mime type in PKGBUILD?

Hi,
I am about to create an AUR package for an application that I wrote. I want to define a dedicated mime type for some file types that this application processes and to set my application as default application for that mime type. The XML for the new mime type and the .desktop file for my application is part of the source code. I wold like to use xgd-utils.

My question: How and where do I do this in the PKGBUILD file?

Just for clarification: I know how to define a mime type and a default application in general.

Thanks and best regards,
mipi

Last edited by mipi (2018-01-03 09:38:51)

Offline

#2 2018-01-03 10:11:18

progandy
Member
Registered: 2012-05-17
Posts: 5,190

Re: Where to set default application for a mime type in PKGBUILD?

Just copy the xml file to /usr/share/mime/packages and the desktop file to /usr/share/applications. Nothing else is necessary since pacman already runs update-mime-database and update-desktop-database for you. If your application is the only one handling the mime type, it is already the default. If there are multiple applications for the mime type, then each user has to choose the default with e.g. "xdg-mime default" or some other tool. No package should change the default.


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#3 2018-01-03 11:14:31

mipi
Member
From: Germany
Registered: 2018-01-03
Posts: 44

Re: Where to set default application for a mime type in PKGBUILD?

Thanks!

Offline

#4 2018-01-03 13:29:41

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: Where to set default application for a mime type in PKGBUILD?

progandy wrote:

If there are multiple applications for the mime type, then each user has to choose the default with e.g. "xdg-mime default" or some other tool. No package should change the default.

... And it is also worth noting that the system does have its own default, unless a user explicitly specifies an overridden per-user default using "xdg-mime default" or some such.

The system default is, unfortunately, chosen via RNG. And re-chosen every time update-desktop-database is run.

So users will have to select their own default, or it will randomly change every time any desktop file on your system is installed, updated, or removed.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#5 2018-01-03 14:47:37

progandy
Member
Registered: 2012-05-17
Posts: 5,190

Re: Where to set default application for a mime type in PKGBUILD?

Eschwartz wrote:

The system default is, unfortunately, chosen via RNG. And re-chosen every time update-desktop-database is run.

I'm thinking about creating a pacman hook that maintains an ordered /usr/share/applications/mimeapps.list for default applications, ordered by the pacman transaction and then alphabetical order of the desktop files.
A system-wide manual default can be set in /etc/xdg/mimeapps.list.

Last edited by progandy (2018-01-03 14:47:50)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#6 2018-01-03 15:24:07

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: Where to set default application for a mime type in PKGBUILD?

Hmm, something that would operate in append-only mode to add new applications, while removing ones that have been removed from the system?

This really should be the desktop-file-utils default, IMO.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

Board footer

Powered by FluxBB