IDEA: Improved File Association management via winecfg

Open forum for end-user questions about Wine. Before asking questions, check out the Wiki as a first step.
Forum Rules
Locked
Fincer
Level 1
Level 1
Posts: 8
Joined: Tue Feb 11, 2014 6:08 pm

IDEA: Improved File Association management via winecfg

Post by Fincer »

I didn't find another place to present the following idea to Wine community, so I put it here for the time being.

Introduction

We have winemenubuilder.exe to find program-related file associations. However, its current method has several unresolved problems:
  • winemenubuilder.exe doesn't consider whether user want to add file association linked to specific program. Instead, winemenubuilder.exe builds links between file types and programs without any user interaction or acceptance by default. You can change winemenubuilder behavior via registry but this is not a straightforward and user-friendly solution. And you still can't easily control file associations for individual programs.
  • Wine can really mess up with your system file associations at the moment. Once you install a Windows program, you may have bunch of unwished "Open with" entries, such as "Open with Internet Explorer" though you have never wanted your system even to suggest that alternative. I've had several times these "polluted situations" and fixing them takes considerably my valuable time.
  • Once Wine has polluted your Linux file open dialogs and you want to get rid of all that stuff, the only certain solution is to remove all wine-extension entries in
    • .local/share/applications/
      .local/share/mime/
      .local/share/icons/16x16/apps/
      .local/share/icons/32x32/apps/
      .local/share/icons/48x48/apps/
File Management via Winecfg

Better controlled and easier-to-manage solution is preferred. That's why I came up with an idea to merge part of winemenubuilder.exe behavior to winecfg. Yes, winecfg. Why?

Winecfg acts currently pretty much as a control center for your wineprefixes and daily Wine administration tasks. File association management is quite natural feature to be added as we think about centralized management for a wineprefix overall. And as an administrator, you want your job just to get done. Manually fixing errors that Wine has made into your system with file associations is pretty far from easy management. Actually, at the current state, configuring file associations on Wine has not management at all. It's just a pre-decided and automated arbitrary solution done ruthlessly by winemenubuilder.exe.

File Associations tab added to winecfg:
Image

winecfg - File Association Management Menu

Generating a list of file associations - basic principle:
  • Find all executables (*.exe) inside the selected wineprefix folder
  • Find the executables that have file associations within them
  • (Exclude all exes that don't have any file associations)
  • Make a list of the executables that have file associations
  • Add specific file associations to the related executable and display them on a list in winecfg (see picture below)
Image

GUI legend/explanation:
  • Tree structure with checkboxes
  • "System Default" = If checked, override user current "open with" settings and set the listed program as a primary application to this file type on Linux system. If unchecked, add this file type as an alternative into "open with" dialog but do not set the Wine program as a system primary choice.
  • "Reset to Defaults" = Reset all associations to winemenubuilder defaults. This also restores all programs originally listed but deleted afterwards by an user.
  • "Check All" = Check all File Type checkboxes
  • "Uncheck All" Uncheck all File Type checkboxes
  • "Add application..." = Add an user-defined application which is not on the list -> Generate file association list to this app
  • "Remove application" = Remove application from the list and delete all file associations linked to it (maybe this option should be available only to user-defined applications but not to the ones already installed in the selected prefix? Just to avoid mess-up)
Removing a file association - basic principle
  • Unmark the specific file type checkbox on file association list
  • Save settings in winecfg
  • Find the matching png icon files in .local/usr/share/icons -> Delete
  • Find the matching desktop file in .local/usr/share/applications -> Delete
  • Find the matching mimetype stuff in .local/share/mime/ -> Delete
  • Update .local/share/applications/mimecache.cache file
  • Update linux file type associations (user priviledges)
Adding a file association - basic principle
  • Mark the specific file type checkbox on file association list
  • Save settings in winecfg
  • Winemenubuilder: link the checked file type to the specific program and...
  • ...add png icon files in .local/usr/share/icons
  • ...add desktop file in .local/usr/share/applications
  • ...add mimetype stuff in .local/share/mime/
  • ...update .local/share/applications/mimecache.cache file
  • ...update linux file type associations (user priviledges)
I have already filled a "bug" report on Wine Staging Buzilla for this. See
https://bugs.wine-staging.com/show_bug.cgi?id=122

Pictures presented in this post are photoshopped just to illustrate the idea.
Fincer
Level 1
Level 1
Posts: 8
Joined: Tue Feb 11, 2014 6:08 pm

Re: IDEA: Improved File Association management via winecfg

Post by Fincer »

Thanks for the link, dimesio. I read that through.

It seems that some people there tend to argue that you should disable winemenubuilder via winecfg and that solves your problem at once. This is not an acceptable solution, it is just a lazy workaround and does not answer the question: How can you manage individual file types on Wine at the moment? The answer is simple: you can't.

You have two bad choices:
  • Disable winemenubuilder completely (and by doing that you need to configure file associations afterwards and you have a risk that those manually configured associations will still exist on your system even after deleting the whole wineprefix)
  • Accept the fact to fill your Mime type list with completely unneeded Wine apps (such as Notepad or Internet Explorer). Delete unneeded associations manually and keep the good ones.
Choosing either one is not a good solution. It's like a black/white situation: you just need to choose the lesser evil choice.

The main problem with disabling winemenubuilder is that you will have no associations at all then. What to do if an user still wants to associate, for example, Word documents (docx, doc...) with Microsoft Word 2010 but doesn't want any other file type associations to be made? On the current state, Wine doesn't act that way and doesn't include any user-friendly tools to work with individual file associations.

You can still have associations correctly for docx and doc types, but with a price of bunch of unwanted types as an extra payload (let me call this situation as a "Polluted file associations" scene, you can find examples by googling them). If you want to get rid of those unneeded associations but keep important ones for docx/doc, you will need to update the system mime types manually. For average computer users, this is a troublesome and unexpected situation. To confront this situation, an easier approach for managing file type associations should be provided for them by default.

The average user I refer to is an user
  • ...without advanced technical knowledge or...
  • ...without knowledge of wine-related tweaks (such as disabling winemenubuilder in Winecfg) or...
  • ...without interest/will/time to configure the system file associations in advanced level every time when applications are installed on Wine
Let me ask honestly:
It's 2015. Winemenubuilder hasn't been updated since 2008 or 2011, at least what the source code (winemenubuilder.c) and several websites tell me. More people are likely interested in to move from Windows to Linux environment. And by being earlier Windows users, they likely need some Windows applications as well. How can it be that there is still not a good file association management integrated to Wine by default for them and for the rest of us? How can it be expected that these earlier Windows users already would have all the knowledge for winecfg tweaks or high knowledge of their fresh Linux systems? If configuring file associations for Windows applications is still this troublesome even after these years, it may increase the threshold to keep Linux in daily usage for some users. I admit that moving to Linux and learning an administrator tweaks has - and will always have - a learning curve of its own but doing things always the hard way is not the best approach to the problems and issues which have clearly existed for years and years and everyone knows that. Wine developers have done excellent job and I must be 1000x thankful for that but still I need to say that managing file associations via GUI is one of the fundamental functions that should already be implemented to Wine by default. With no offense.
User avatar
dimesio
Moderator
Moderator
Posts: 13201
Joined: Tue Mar 25, 2008 10:30 pm

Re: IDEA: Improved File Association management via winecfg

Post by dimesio »

Find all executables (*.exe) inside the selected wineprefix folder
That's too late. Winemenubuilder creates the file associations when installers are run.

As for the rest of it, to me your proposal looks like more work for the user than simply using whatever tools the desktop environment provides. KDE has a very user-friendly GUI for managing file associations. I see no advantage to replicating those functions in winecfg, and I do see a disadvantage: your way requires the user to run winecfg and configure the associations separately for each and every wineprefix, whereas managing the file associations through the DE's controls takes care of all wineprefixes.
Fincer
Level 1
Level 1
Posts: 8
Joined: Tue Feb 11, 2014 6:08 pm

Re: IDEA: Improved File Association management via winecfg

Post by Fincer »

I understand your point about multiple winecfg's with multiple file association management functions. From that point view, your argument makes completely sense. However, I would also talk about situation *before* the associations are really created. Configuring them via KDE menu is an *after* scene. I.E. Let me say it clearly: Configuring associations via KDE menus is a situation where "the shitload of Wine file associations have already polluted your system and you need to remove them manually". I'm trying to find a way to prevent this from happening in the first place without disabling winemenubuilder because some of file associations it creates are still very useful.

I pondered the question about file associations all over again maybe an hour or so: alternatives, choices, possibilities, everything.

This is just a wild suggestion so please, do not condemn it: One possibility could be to store winemenubuilder file associations to a single or multiple configuration file(s) (instead of accepting them all by default) while installing a program. Additional configuration file could give a possibility to add to/remove Wine file associations from Linux system if ever needed, with *user control*. Via this configuration file, user could enable or disable Wine file associations and manage them easily. By running a specific wineprefix any changes that have been made to the configuration file would be read and applied to the system as well.

I know it's not a straightforward solution, maybe even unacceptable, impossible or bad one. However, it illustrates the idea of giving more user control over Wine file associations created by winemenubuilder.

After all, the main point is that I wish there would be easier way to manage which file types you want to associate with your Wine programs and which ones to exclude. I don't need like 5-10 internet explorers to open a single html file, if you know what I mean. I need none of them. I need no any Wine-related associations or icon files to be created for xml files. I already have firefox on Linux and I'm extremely happy with my Faenza icon theme. I don't want waste my time to fix errors that Wine has made to my system without my conscious permission. However, I still want particular fle associations to be created, such as ones for docx/doc file types. What tools does Wine or Linux offer me to do what I want?

However, this seems to be an very difficult/challenging request due to structure of Wine/Linux system or/and lack of interest in development or/and time it would take to implement it. We still need to deal with the issue in traditional ways. And traditional ways may lead to problems with an average user in some circumstances. Maybe that's just the price to pay when using Linux with Windows software mixed within, I don't know. Winemenubuilder does partially a great job but having more control on what it does would be preferred, anyway.
User avatar
dimesio
Moderator
Moderator
Posts: 13201
Joined: Tue Mar 25, 2008 10:30 pm

Re: IDEA: Improved File Association management via winecfg

Post by dimesio »

Fincer wrote: I don't want waste my time to fix errors that Wine has made to my system without my conscious permission. However, I still want particular fle associations to be created, such as ones for docx/doc file types. What tools does Wine or Linux offer me to do what I want?
Disable winemenubuilder in .bashrc and enable it selectively on the command line when running installers for the apps for which you want file associations created. Or just create the file associations manually in whatever tool your desktop environment provides.

The real problem I see with the current situation is that disabling winemenubuilder prevents the creation of both file associations and menu entries, so people who want one or the other, but not both, have to either delete what they don't want or manually create what they do. It would be helpful for users to have a way to selectively disable one or the other.
Fincer
Level 1
Level 1
Posts: 8
Joined: Tue Feb 11, 2014 6:08 pm

Re: IDEA: Improved File Association management via winecfg

Post by Fincer »

Disable winemenubuilder in .bashrc and enable it selectively on the command line when running installers for the apps for which you want file associations created.
I may try this as a temporary solution. Thank you! This is something at least (but still not an ultimate solution, though).
Or just create the file associations manually in whatever tool your desktop environment provides.
I've tried to find useful tools to improve file association management for Wine programs. I haven't had so much luck with that, unfortunately.
The real problem I see with the current situation is that disabling winemenubuilder prevents the creation of both file associations and menu entries, so people who want one or the other, but not both, have to either delete what they don't want or manually create what they do. It would be helpful for users to have a way to selectively disable one or the other.
I'm not sure if I follow you with the terminology but as far as I understand, that's pretty much the situation. After all, winemenubuilder should be more flexible with the creation of file associations (more user control, if ever requested). Automatically created associations are troublesome especially when multiple wineprefixes are used on the system. Winemenubuilder also tend to create many random & unwanted entries, such as for notepad/internet explorer. For example, If I create a single prefix only for my Adobe Photoshop CS2, winemenubuilder will still create notepad/IE entries by default, too. And all I ever wanted were associations just for PSD/PSB and all other *Photoshop only* file types. Nothing more, nothing less. The same situation will be faced with every single Wine program I want install on my Linux system.

Anyway, thank you for your helpful and receptive reply!
Locked