You are not logged in.

#1 2013-07-18 16:46:44

spurious_access
Member
Registered: 2013-02-23
Posts: 15

Easy way to set xdg-open defaults? (No DE) [Solved]

I've decided to go more lightweight this time around so instead of using a DE I'm just using an OpenBox standalone setup. However, I've noticed that there is no mimeapps.list generated by default, so my file manager (mucommander) doesn't know what to do with files if I tell it to open them. I've now added a few file types using xdg-mime but that's going to be a real pain if I have to do that for every mime type that every application supports. Is there an easier way to set the default applications or generate a pre-populated mimeapps.list, or maybe a way to just accept all the supported mime types for a given .desktop file? Or anything easier then setting this all up manually using the mimeapps.list file or the "xdg-mime default" command?

Edit:
I'm not sure why originally muCommander didn't want to open some of the files I tried, it could be that the ones I was testing didn't have any applications installed to handle them or something. As far as an easy way to make changes to mimeapps/default.list configuration, some have suggested using mimeo which (from what I can tell) offers similar functionality to xdg-mime, which is still a bit more work than I was looking for. I ended up just using Thunar to manage the default applications, as the way it handles this configuration is by reading/modifying the users mimeapps.list file which is exactly what I was looking for.

Last edited by spurious_access (2013-07-21 21:26:22)


ghostwheel | Custom | Arch with linux-ck-nehalem |  x86_64 | BIOS | grub2 | systemd | BTRFS | Intel Core i7 920 @ 3.2 GHz | 18GB RAM | 80gb Intel 320 SSD (boot) | 1.5TB 7200 RPM Seagate HDD (storage)

hactar | Google CR-48 | Arch with linux-ck-atom | x86_64 | EFI | grub2 | systemd | ext4  | Intel Atom | 2GB RAM | 64 gb Kingston SSD | Atheros Wireless

Offline

#2 2013-07-18 17:06:20

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Easy way to set xdg-open defaults? (No DE) [Solved]

No sure how helpful it is, but I found http://unix.stackexchange.com/questions … enviroment
Also https://wiki.archlinux.org/index.php/Xd … placements may offer some benefits over xdg-open.

Offline

#3 2013-07-19 01:39:28

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,168

Re: Easy way to set xdg-open defaults? (No DE) [Solved]

Have you tried xdg-desktop-menu? I ask because the man page mentions mimetypes in desktop files and with that command you can install multiple .desktop and/or .directory files at once. I realise you the point is not to create a desktop menu but I'm wondering if it might add mimetypes as a side-effect. Might be worth trying on a suitable desktop file with currently unrecognised mimetypes just to see.

EDIT: It would be nice to know why update-mime-database doesn't work on Arch, if it really doesn't. It certainly is available on Arch and I can't think what else it might be for...

EDIT EDIT: Is the problem that there is no /usr/share/applications/default.list maintained/generated on Arch?

It really seems like there should be a tool to generate a default...

Last edited by cfr (2013-07-19 01:56:46)


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#4 2013-07-19 02:10:28

Xyne
Forum Fellow
Registered: 2008-08-03
Posts: 6,965
Website

Re: Easy way to set xdg-open defaults? (No DE) [Solved]

cfr wrote:

It really seems like there should be a tool to generate a default...

There is: mimeo wink
It's also mentioned on the wiki page linked above.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#5 2013-07-19 02:16:42

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,168

Re: Easy way to set xdg-open defaults? (No DE) [Solved]

Xyne wrote:
cfr wrote:

It really seems like there should be a tool to generate a default...

There is: mimeo wink
It's also mentioned on the wiki page linked above.

If so, the wiki is very misleading because it suggests that those files already need to exist i.e. that mimeo will open files according to those lists if you already have them. I therefore assumed that would have the same issue: the OP wants a way to generate those lists.

EDIT: Or does "standard" mean provided-by-mimeo rather than what-you-have-already?

EDIT EDIT: Of all the things I miss, OS X's open command is rather weirdly high on my list. That and alpine integration with the keychain.

Last edited by cfr (2013-07-19 02:38:25)


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#6 2013-07-19 02:42:53

Xyne
Forum Fellow
Registered: 2008-08-03
Posts: 6,965
Website

Re: Easy way to set xdg-open defaults? (No DE) [Solved]

Mimeo provides the option "--prefer". This can be used to associate mimetypes (using direct matching, globbing or regexes) with desktop files. These associations are saved in the mimeapps.list and defaults.list files, which should be used by other applications (and obviously by mimeo itself). This conforms to the XDG standards (or at least it did when I wrote it, but that was a while ago now). Not all apps respect the XDG standards, but they seem to be among the most respected out there (that aren't tied to a given DE at least).

To make this completely clear: mimeo reads those files and uses their associations, but it can also be used to update them with new associations (including defaults) as well as remove associations. It can also create custom desktop files for any application via a command-line interface, clean up old/broken associations and desktop files, list mimetypes for files, etc.

The help message with all options is on the project page.

As for the wiki article, I did not write it. I only discovered that mimeo was on that page when I followed the link above. I had to make a quick edit because the wording of the entry implied that mimeo depended on xdg-utils-mimeo, instead of the other way around. I have not read the rest of it so there may be other mistakes and unclear information on that page.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#7 2013-07-19 02:53:27

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,360

Re: Easy way to set xdg-open defaults? (No DE) [Solved]

Just dropped by to say mimeo is the way to go smile


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#8 2013-07-19 02:54:46

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,168

Re: Easy way to set xdg-open defaults? (No DE) [Solved]

Thanks for clarifying. I wasn't suggesting you wrote the wiki page - just explaining that I had read it and it wasn't obvious to me how mimeo could be of assistance. That's clearer now but it is not quite what I had in mind either.

I meant something which would parse all .desktop files, say, and generate a defaults.list associating applications with mimetypes. Of course this would need adjusting since it would have no idea which of multiple possibilities the user might prefer to open a given mimetype but that's so with a DE as well - the environment doesn't tend to agree with all user preferences in terms of default applications. What it does do is set up the basic associations between mimetypes and applications and assign some default, even if not the user's preferred option.

But I can't see anything to generate /usr/share/applications/defaults.list or the user's mimeapps.list automatically from installed .desktop files.

EDIT: maybe the --update option does this?

Last edited by cfr (2013-07-19 02:57:54)


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#9 2013-07-19 14:21:52

Xyne
Forum Fellow
Registered: 2008-08-03
Posts: 6,965
Website

Re: Easy way to set xdg-open defaults? (No DE) [Solved]

ngoonee wrote:

Just dropped by to say mimeo is the way to go smile

big_smile

@cfr
What you want is already standard behavior. You are just confused about the purpose of the defaults.list file. The system does create default associations in mimeapps.list. The purpose of this file is to specify which applications may be used to open which mimetypes. Applications default to the first item in the matching association list, if there is no defaults.list file. The purpose of the defaults.list file is to override the default in mimeapps.list, as it may not be what the user wants and the order of associations may change upon subsequent updates. If X, Y and Z can all open mimetypes of type A, how can the system automatically determine which  application is the "best" default? This is why you sometimes end up opening images with Gimp when you just want to view them quickly. The system cannot possibly know what you want to do when you open the file and Gimp ended up at the beginning of the association list.

Autogenerating defaults.list would not make any sense because you cannot automatically determine what the user will prefer (despite what some DE makers think), and autogenerating it would be no different than rebuilding the mimeapps.list file with a different order for each mimetype. That file is meant to be used by the user only to override the system defaults. In my opinion, "default" is the wrong word and that is partially why I have named the mimeo option "prefer" instead.

To conclude, the --update option will rebuild the mimeapps.list files (both user and system, if run with elevated privileges) and that inadvertently generates default associations by their ordering. The --prefer option is used to update the user's defaults.list file to allow the user to override these defaults.

Why don't you just try mimeo and see how it works yourself? You can always back up your mimeapps.list and defaults.list files if you are worried that it might mangle them. I doubt that it will though. wink


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#10 2013-07-19 16:11:57

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Easy way to set xdg-open defaults? (No DE) [Solved]

https://wiki.archlinux.org/index.php/De … hould_work says distros / DEs providing sane defaults in defaults.list and users overriding them in mimeapps.list is the way to go.

Note that the upstream, yet unreleased xdg-utils were fixed to use mimeapps.list instead of defaults.list but the xdg-open bug (specifying multiple applications breaks it completely) still remains.

I'm not using xdg-utils, and I have no idea what's the current state of affairs, but it's a tiny bit confusing:
* you don't touch A defaults, you just override it with B
* actually B is the new default
* but it's still broken

Offline

#11 2013-07-19 17:47:27

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,722

Re: Easy way to set xdg-open defaults? (No DE) [Solved]

@Xyne nigga yo got a nue customer here. Fix ya typo `$SDG_DATA_DIRS' or me gonna call ya boss.

Edit:
This is not the best thread for this, but I'm just gonna append it here...
@Xyne, I think with --prefer, the preferred desktop file should be inserted at the start in mimeapps.lst, e.g. after these commands:

$ mimeo --prefer image/png eog.desktop
$ mimeo --prefer image/png gimp.desktop

I expect the mimeapps.lst to look like this:

[Added Associations]
image/png=gimp.desktop;eog.desktop;

but instead, mimeo leaves it like this:

[Added Associations]
image/png=eog.desktop;gimp.desktop;

It supposedly doesn't matter for the *default* app, since defaults.lst is correctly updated, but for me, my "prefer" should be reflected in mimeapps.lst too. I also don't quite like defaults.lst coz it's sooo surplus to me.

Last edited by lolilolicon (2013-07-19 18:11:18)


This silver ladybug at line 28...

Offline

#12 2013-07-19 20:54:52

Xyne
Forum Fellow
Registered: 2008-08-03
Posts: 6,965
Website

Re: Easy way to set xdg-open defaults? (No DE) [Solved]

@karol
I have now followed the situation's development but it was a still a big mess the last time that I made any real changes to Mimeo. When I finally get around to rewriting it, I plan to follow all of the XDG recommendations.

@lolilolicon
The typo has been fixed and association lists will now be prefixed with preferred desktop files.

While I understand how the first part of your post was meant, others might not. Please refrain from using such language on these boards.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#13 2013-07-19 21:19:24

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,168

Re: Easy way to set xdg-open defaults? (No DE) [Solved]

karol wrote:

https://wiki.archlinux.org/index.php/De … hould_work says distros / DEs providing sane defaults in defaults.list and users overriding them in mimeapps.list is the way to go.

Note that the upstream, yet unreleased xdg-utils were fixed to use mimeapps.list instead of defaults.list but the xdg-open bug (specifying multiple applications breaks it completely) still remains.

I'm not using xdg-utils, and I have no idea what's the current state of affairs, but it's a tiny bit confusing:
* you don't touch A defaults, you just override it with B
* actually B is the new default
* but it's still broken

I was actually going by https://wiki.archlinux.org/index.php/Xd … onfig_file which says

xdg-open uses configuration files located at $XDG_DATA_HOME/applications/mimeapps.list (for a single user; $XDG_DATA_HOME defaults to ~/.local/share) and /usr/share/applications/defaults.list (system wide). Its format is as follows:

[Default Applications]
mimetype=desktopfile1;desktopfile2...

For example:

[Default Applications]
text/html=firefox.desktop
inode/directory=kde4-dolphin.desktop;Thunar.desktop;nautilus.desktop

which doesn't even mention the user-specific defaults.list Xyne mentioned. So when I talked about defaults.list being autogenerated, I meant something for system-wide use. And for mimeapps.list, I just meant something to get the possible associations listed from the .desktop files. Obviously that would then need to be tweaked by the user but I took it that the OP was trying to find a way of just getting the possible associations in there to begin with, never mind setting some as preferred over others. And it wasn't clear to me mimeo did that from looking at the options so it is good to know that it can do that as well as configure preferences.

I would install it to try but I am worried that it may disagree with KDE and since I can set preferred apps through KDE, I am not missing much (except, obviously, the particular features of OS X's open command which I miss i.e. multiple files and -a). So I tend to err on the side of caution...


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#14 2013-07-20 06:30:58

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,722

Re: Easy way to set xdg-open defaults? (No DE) [Solved]

Xyne wrote:

@lolilolicon
The typo has been fixed and association lists will now be prefixed with preferred desktop files.

While I understand how the first part of your post was meant, others might not. Please refrain from using such language on these boards.

Thanks for the quick fix.
Sorry dude. It was too trivial an issue I didn't know any other way to point it out. I was kind of in a "Wacka wacka, bitches!" spirit.

Edit:
What about --unprefer? I think the target .desktop, if it is indeed previously the preferred default, should be pop(0)'d from (or moved to the last of?) the list in mimeapps.lst, in addition to being removed from defaults.lst.

Last edited by lolilolicon (2013-07-20 07:03:28)


This silver ladybug at line 28...

Offline

#15 2013-07-21 20:54:42

Xyne
Forum Fellow
Registered: 2008-08-03
Posts: 6,965
Website

Re: Easy way to set xdg-open defaults? (No DE) [Solved]

lolilolicon wrote:

Sorry dude. It was too trivial an issue I didn't know any other way to point it out. I was kind of in a "Wacka wacka, bitches!" spirit.

Don't worry, I completely got it. I have those moments too. That's one of the reasons that I don't send half my replies when I'm tired. tongue

lolilolicon wrote:

Edit:
What about --unprefer? I think the target .desktop, if it is indeed previously the preferred default, should be pop(0)'d from (or moved to the last of?) the list in mimeapps.lst, in addition to being removed from defaults.lst.

I thought that "--remove" would remove the default association but didn't. I have updated it to do so. I considered updating "--unprefer" to move associations to the end of the list but the current code is too much of a mess to fit that in cleanly. I don't want to put any real effort into improving the current code when I plan to completely rewrite it with a much better (read: an actual) design when I have the time. Among other things I may provide a way to select the order of the associations from the command line.

Besides, simply "unpreferring" an association does not necessarily mean that it should go to the end of the list. If the user never wants to use it, then "--remove" does the job. If the user wants to prefer something else then it can be set with "--prefer". For now, at least. my ideas will evolve with the rewrite, but that probably won't happen any time soon given my current todo list and lack of time.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#16 2013-07-21 21:19:50

spurious_access
Member
Registered: 2013-02-23
Posts: 15

Re: Easy way to set xdg-open defaults? (No DE) [Solved]

Hi guys, thanks for all the info!

I originally hadn't realized that you don't actually need a defaults.lst/mimeapps.lst, since it will just pick the first desktop file it ran across to use, so the idea of going through all the desktop files and manually entering every mime type with the appropriate application seemed a bit daunting and unnecessary. I saw mimeo mentioned in the wiki, but it seemed to include similar functionality to xdg-mime, meaning you would have to go through and enter the command for every mime type, which would mean knowing the exact mime type from the beginning and doesn't seem much easier than editing the defaults file, which wasn't quite what I was hoping for.

I ended up just installing Thunar and using that to change a few of the default associations, since the way that it saves and gets it's "open with" settings is based on mimeapps.lst. For me, this is an acceptable solution as it allows for changes to be easily made on the fly without having to do too much work figuring out the different mime types.


ghostwheel | Custom | Arch with linux-ck-nehalem |  x86_64 | BIOS | grub2 | systemd | BTRFS | Intel Core i7 920 @ 3.2 GHz | 18GB RAM | 80gb Intel 320 SSD (boot) | 1.5TB 7200 RPM Seagate HDD (storage)

hactar | Google CR-48 | Arch with linux-ck-atom | x86_64 | EFI | grub2 | systemd | ext4  | Intel Atom | 2GB RAM | 64 gb Kingston SSD | Atheros Wireless

Offline

#17 2013-07-22 03:06:56

Xyne
Forum Fellow
Registered: 2008-08-03
Posts: 6,965
Website

Re: Easy way to set xdg-open defaults? (No DE) [Solved]

@spurious_access
Use whatever is most convenient for you, but I want to mention that mimeo supports both glob patterns and regular expressions for creating associations, so you can do much more much faster than you can with e.g. thunar. It also has an option to give you the mimetype of files on the command line, so it's not really more work to figure that out either.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

Board footer

Powered by FluxBB