how do i associate mime types with wine types in linux?

Open forum for end-user questions about Wine. Before asking questions, check out the Wiki as a first step.
Forum Rules
Locked
protozone
Level 1
Level 1
Posts: 7
Joined: Sun May 20, 2018 8:50 pm

how do i associate mime types with wine types in linux?

Post by protozone »

i am wondering,

how do i set Debian Linux (w/ XFCE) so that when I click on a PNG file, it always opens up PhotoFiltre7?

( assume that I have PhotoFiltre in c:\Program Files\PhotoFiltre7\photofiltre.exe )

please show me the complete syntax, thanks.
wildtux
Level 3
Level 3
Posts: 56
Joined: Sat Aug 13, 2016 10:05 am

Re: how do i associate mime types with wine types in linux?

Post by wildtux »

you have to create a desktop file in /home/'user'/.local/applications looking like this:

Code: Select all

[Desktop Entry]
Type=Application
Name=Wine PhotFiltre7
MimeType=image/jpeg;
Exec=env WINEPREFIX="/home/'user/'your_wine-prefix" wine start /ProgIDOpen jpegfile %f
NoDisplay=true
StartupNotify=true
Icon='PhotoFiltre_icon'
I have not the exact mime syntax for this, so the Exec line is not probably accurate. I bet PhotoFilltre7 has a proper mime association tool in its config, If you look into it, it will associate the file you want and Wine will create associated desktop files, then you could open image files with 'open with' in file context menu.
User avatar
Bob Wya
Level 12
Level 12
Posts: 3068
Joined: Sat Oct 16, 2010 7:40 pm

Re: how do i associate mime types with wine types in linux?

Post by Bob Wya »

protozone wrote:i am wondering,

how do i set Debian Linux (w/ XFCE) so that when I click on a PNG file, it always opens up PhotoFiltre7?

( assume that I have PhotoFiltre in c:\Program Files\PhotoFiltre7\photofiltre.exe )

please show me the complete syntax, thanks.
Wine should actually create native Linux mime-type files by default...

Take a look at the output from:

Code: Select all

find "${HOME}/.local/share/applications/" -type f -name "wine-extension-*.desktop"
So you should be able to make file type associations, with whatever tool your Desktop Environment provides to do this...

To enable these to be "seen" by your native Linux Desktop Environment. You need to create the following file:
/etc/xdg/menus/applications-merged/wine.menu

Code: Select all

<!DOCTYPE Menu PUBLIC "-//freedesktop//DTD Menu 1.0//EN"
 "http://www.freedesktop.org/standards/menu-spec/menu-1.0.dtd">
<Menu>
  <Name>Applications</Name>
  <Menu>
    <Name>wine-wine</Name>
    <Directory>wine-wine.directory</Directory>
    <Include>
      <Category>Wine</Category>
    </Include>
    <Menu>
      <Name>wine-Programs</Name>
      <Directory>wine-Programs.directory</Directory>
      <Include>
        <Category>Wine-Programs</Category>
      </Include>
      <Menu>
        <Name>wine-Programs-Accessories</Name>
        <Directory>wine-Programs-Accessories.directory</Directory>
        <Include>
          <Category>Wine-Programs-Accessories</Category>
        </Include>
      </Menu>
    </Menu>
  </Menu>
</Menu>
Bob
protozone
Level 1
Level 1
Posts: 7
Joined: Sun May 20, 2018 8:50 pm

Trying to open a PNG with PhotoFiltre by default

Post by protozone »

Hey guys, thanks for the quick replies.
I will try out what you told me about... none of that is very familiar to me.

My intention is to be able to just click on a PNG file and it load PhotoFiltre7 instead of GIMP or Ristretto or whatever my Linux uses. I like most Linux programs, but for a few types of files, I only want my Wine program by default.

I tried associating manually via the "open with..." dialog box, but I couldn't get that to work for Wine programs. I know it can be done though, somehow... I just forgot the syntax.

Any other suggestions in the meantime of some alternative techniques or more details?
User avatar
Bob Wya
Level 12
Level 12
Posts: 3068
Joined: Sat Oct 16, 2010 7:40 pm

Re: Trying to open a PNG with PhotoFiltre by default

Post by Bob Wya »

protozone wrote:
Any other suggestions in the meantime of some alternative techniques or more details?
Ha, ha, you've opened a can of worms there! :shock:

The native Linux XDG specification is used for MIME-type handling under Wine.
See: Arch Wik: XDG MIME Applications.

The Wine builtin helper utility winemenubuilder builds the Wine menu entries and MIME associations.
See: winemenubuilder.c

Bob
protozone
Level 1
Level 1
Posts: 7
Joined: Sun May 20, 2018 8:50 pm

How to open a windows filetype in Linux by default

Post by protozone »

Hey thanks for the help.

I think you guys got me a working solution:

1) create a launcher on the desktop (right-click)
2) set up the launcher's properties
3) select the EXE program via the window
4) put single quotes (') on each side of the EXE's full filename path (and do NOT use "%f")
5) edit the launcher in leafpad editor to clean up anything or add anything like comments
6) set the launcher to executable permission
7) move the launcher to /usr/share/applications (in root mode)
8a) now the launcher entry works like the Linux entries for the applications menu and the "Open with..." dialog!
8b) (this can work with the "default" checkbox)

Thanks! This worked for me in Wine-staging
User avatar
Bob Wya
Level 12
Level 12
Posts: 3068
Joined: Sat Oct 16, 2010 7:40 pm

Re: How to open a windows filetype in Linux by default

Post by Bob Wya »

protozone wrote:Hey thanks for the help.

I think you guys got me a working solution:

1) create a launcher on the desktop (right-click)
2) set up the launcher's properties
3) select the EXE program via the window
4) put single quotes (') on each side of the EXE's full filename path (and do NOT use "%f")
5) edit the launcher in leafpad editor to clean up anything or add anything like comments
6) set the launcher to executable permission
7) move the launcher to /usr/share/applications (in root mode)
8a) now the launcher entry works like the Linux entries for the applications menu and the "Open with..." dialog!
8b) (this can work with the "default" checkbox)

Thanks! This worked for me in Wine-staging
Wine is already doing these steps (creating desktop launcher files) below:

Code: Select all

~/.local/share/applications/
and extracting the Windows application icons below:

Code: Select all

~/.local/share/icons/
You can't see this because your Wine package is missing the necessary Desktop Integration files.
So your Desktop Environment ignores the winemenubuilder generated files at present.

I've got a Github repository with all the necessary Integration files and some hi-res Wine icons (for the builtin utilities).
See: Github: bobwya / wine-desktop-common.

I often manually create .desktop files for my Wine applications.
But personally I just use vim or something to do it (they are only text files after all).

Bob
protozone
Level 1
Level 1
Posts: 7
Joined: Sun May 20, 2018 8:50 pm

Re: How to open a windows filetype in Linux by default

Post by protozone »

protozone wrote:Hey thanks for the help.

I think you guys got me a working solution:

1) create a launcher on the desktop (right-click)
2) set up the launcher's properties
3) select the EXE program via the window
4) put single quotes (') on each side of the EXE's full filename path (and do NOT use "%f")
5) edit the launcher in leafpad editor to clean up anything or add anything like comments
6) set the launcher to executable permission
7) move the launcher to /usr/share/applications (in root mode)
8a) now the launcher entry works like the Linux entries for the applications menu and the "Open with..." dialog!
8b) (this can work with the "default" checkbox)

Thanks! This worked for me in Wine-staging

Ooops! I forgot to mention something important: At step 4, I put "wine " in front of the EXE's full filename path, so that it looks kinda like this inside of the launcher...

Code: Select all

[Desktop Entry]
Version=1.0
Type=Application
Name=PhotoFiltre
Comment=Image Editor
Exec=wine '/home/ (MYUSERNAME) /.wine/drive_c/Programs/PhotoFiltreSeven/PhotoFiltre7.exe'
Icon=applications-graphics
Path=
Terminal=false
StartupNotify=true
GenericName=PhotoFiltre 7
Categories=Graphics;
Locked