Associate .3mf files with PrusaSlicer

Asked by Tyler R

Double clicking a .3mf file in linux results in an archive manager opening. in my case Archive Manager/ File Roller. I would like it to open with PrusaSlicer.

If I right click on the file and use the Properties -> Open With tab to change the default program to PrusaSlicer ALL compressed file types (eg. .zip or .rar) try to open with PrusaSlicer which obviously is not wanted.

Obviously I could right click on the file and Open With PrusaSLicer every time, but its annoying.

I am not familiar enough with linux to know if this is an issue on Ubuntu's side or PrusaSlicer's. I think it has something to do with MIME Types.

Is this something that can happen when the package is built?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu xdg-utils Edit question
Assignee:
No assignee Edit question
Solved by:
Daniel Letzeisen
Solved:
Last query:
Last reply:
Revision history for this message
Tyler R (yossarianmtu) said :
#1

Ubuntu 20.04.4
DE: MATE
PrusaSlicer 2.4.2

Revision history for this message
Bernard Stafford (bernard010) said :
#2

Did you install PrusaSlicer with a Snap Package ?
  https://snapcraft.io/prusa-slicer
Or by .deb in the repository?
 You could try Right click on file-> Open With -> Open with another application
-> Pick the Application from the list -> Check the 'use as default for this type of file'
It still may have the same results.

Revision history for this message
Manfred Hampl (m-hampl) said :
#3

What is the output of the command (to be execited in a terminal window)

grep 3mf /etc/mime.types

Revision history for this message
Tyler R (yossarianmtu) said :
#4

Bernard,
I thought it was through apt, but now I see it is the snap package.

"You could try Right click on file-> Open With -> Open with another application
-> Pick the Application from the list -> Check the 'use as default for this type of file'
It still may have the same results."

It seems to have the same unwanted behavior.

Manfred,
the command has no output and an exit code of 1.

I've been reading about mime types and now know that I'm in way over my head, but I think its the solution. Do I need to contact the Snap Package builder?

Thanks for the responses guys.

Revision history for this message
Daniel Letzeisen (dtl131) said :
#5

The snap package shouldn't have anything to do with it. You'll get the same behavior with the .deb of prusa slicer.
3mf files are of mimetype application/zip just like zip files, so unfortunately, I don't see a way to do what you want.

Revision history for this message
Manfred Hampl (m-hampl) said :
#6

If David Letzeisen's comment is true (which I assume), then the only possibility would be to define a separate mime type for 3mf files, different from application/zip. Then it should be possible to associate that new type with prusa slicer without affecting the other zip files.

Revision history for this message
Daniel Letzeisen (dtl131) said :
#7

Yeah, Manfred, I'm not sure if creating a new mime type and associating it with the 3mf extension will work. I don't know if you can override an existing mimetype in favor of a filename extension. There are pros and cons to treating filename extensions as a special thing like Windows/NTFS does. This is one of the cons.

Tyler, I'm not sure about GNOME/Nautilus, but in xfce/Thunar, doing what you want only requires a right click and a left click once you've associated prusa slicer with zip files and set the default back to an archiver program. (I tested in my 20.04 Xubuntu VM).
"Open with prusa slicer" should appear in the right-click context menu without having to choose it from a list. Granted, it's not as convenient as a double click, but a right click and a left click doesn't seem too bad to me. That may be the closest thing to what you want, even if it's not perfect.

Revision history for this message
Tyler R (yossarianmtu) said :
#8

Manfred and Daniel,
That is what I am looking for, I just dont know how to do it. I found a user with i similar problem and solution here:

https://askubuntu.com/questions/1286360/set-default-application-by-extension-not-mimetype

I think this would work for prusaslicer. I just don't understand enough about the code block they present to modify it for my use case. I would think this would be a great benefit for the linux version of prusaslicer. While right click, left click thing works it sure would be great to just double click a file.

Revision history for this message
Best Daniel Letzeisen (dtl131) said :
#9

Okay, this might work. It seemed to work in my VM:

Make a file named ~/.local/share/mime/packages/application-x-3mf.xml with vim or whatever text editor you like:

Copy and paste:

<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
  <mime-type type="application/x-3mf">
     <comment>3D Manufacturing Format</comment>
     <icon name="application-x-3mf"/>
     <glob-deleteall/>
     <glob pattern="*.3mf"/>
  </mime-type>
</mime-info>

Then run:
update-mime-database ~/.local/share/mime

And finally, edit ~/.config/mimeapps.list and add the following line to the [Added Associations] section:
application/x-3mf=prusa-slicer.desktop

Revision history for this message
Tyler R (yossarianmtu) said :
#10

Daniel,
That works great! Thank you! anyway to make this happen on install for everyone else?

Revision history for this message
Tyler R (yossarianmtu) said :
#11

Thanks Daniel Letzeisen, that solved my question.

Revision history for this message
Daniel Letzeisen (dtl131) said :
#12

Maybe?:
sudo xdg-mime install --mode system ~/.local/share/mime/packages/application-x-3mf.xml
sudo xdg-mime default prusa-slicer.desktop application/x-3mf

Revision history for this message
Tyler R (yossarianmtu) said :
#13

Sorry, I wasnt very clear. I would like to make this the default behavior for anyone on any computer who installs this package. That way everyone can benefit from this. Where do I need to post a bug report/feature request to make this default for PrusaSlicer in the repo/snap package? PrusaSlicer's github? Or is this something the Ubuntu package maintainers do? I'm not familiar enough with how packaging works to know where the responsibility would fall.
Thank you again for your help.

Revision history for this message
Daniel Letzeisen (dtl131) said :
#14

I believe the commands I posted will do what you want. You only need to run them one time.

Revision history for this message
Daniel Letzeisen (dtl131) said :
#15

Oh, I misunderstood. Now I see what you're saying.. I'm not sure how to go about doing that.

Revision history for this message
Daniel Letzeisen (dtl131) said :
#16

Okay, so after some more research, it does appear 3mf has its own mime type and that upstream prusa slicer declares it in the .desktop file:
https://github.com/prusa3d/PrusaSlicer/blob/master/src/platform/unix/PrusaSlicer.desktop

So the correct person to contact is the Debian maintainer. Since I use Debian, I went ahead and made a bug report.
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1010585

I hope I explained it correctly.