treesheets icon indicating copy to clipboard operation
treesheets copied to clipboard

.cts files in Linux do not seem to have an assigned Magic Number

Open morciej opened this issue 3 years ago • 9 comments

In Linux, installations need to have the Magic Number to .cts files added.

I believe the file starts with "TSFF\n", but please do correct me if I am wrong. Without it, .cts files are listed as "unknown type" and it is NOT possible to open a .cts file by double clicking on the link, or alternatively ALL files of the type "unknown" are being open by Treesheets (which is not the desirable outcome).

I am not sure who is empowered to request it.

morciej avatar Mar 29 '21 02:03 morciej

what do you mean, "linux" ? is this a specific window manager / file manager under linux (kde / gnome ?) how do programs normally register file extensions or file headers there?

aardappel avatar Mar 29 '21 06:03 aardappel

A MIME type for TreeSheets needs to be added: https://freedesktop.org/wiki/Specifications/AddingMIMETutor/

ghuls avatar Mar 29 '21 08:03 ghuls

Anyone on Linux wants to test adding these files, then send a PR to this repo?

aardappel avatar Mar 29 '21 16:03 aardappel

Sorry, should have been more specific. Linux Mint ulyssa/focal it is. I am using XFCE.

morciej avatar Apr 03 '21 17:04 morciej

OK here's a workaround. I am not skilled enough in github-fu to make a pull request; someone please help.

  1. Add the following lines to /etc/magic and /etc/magic.mime:
0   string  TSFF    treesheets archive
!:mime application/prs.treesheets

This takes care of the first issue, the system not recognizing .cts archives as anything special. Now we'll create the actual mime type.

  1. Add a file named treesheets.xml to /usr/share/mime/packages, containing:
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
   <mime-type type="application/prs.treesheets">
     <comment>Treesheets Archive</comment>
     <glob pattern="*.cts"/>
     <icon name="treesheets"/>
   </mime-type>
</mime-info>
  1. Run sudo update-mime-database /usr/share/mime

Now the mime type application/prs.treesheets exists, and we can use it to associate .cts files with the treesheets application.

  1. Right-click any .cts file in your favourite file manager (FWIW I use thunar, your mileage may vary with others) and select treesheets to always handle this type of file.

END RESULT: treesheets-open

DONE

P.S. I used application/prs.treeshheets for mime type. This makes it a personal mime type. Obviously, the developer needs to use a vnd.xxxxxxx type instead, but it's not my prerogative to select a public mime type.

morciej avatar Jan 23 '22 22:01 morciej

@morciej the instructions you gave are all system changes, as opposed to changes to this repo. So a PR would need to take the form of some kind of install script, that does what you did automatically?

What of your instructions is or isn't applicable to other Linux setups?

aardappel avatar Jan 23 '22 23:01 aardappel

I suppose so. I am not a programmer, just an amateur system administrator of this particular Linux Mint, old beater of a desktop. I never worked with a Slackware/Debian/Ubuntu/Arch/Fedora, so I can't answer these questions. But the idea of magic numbers and mime types is universal to Linux, so it should work, with distribution-specific adjustments, on any. As for how to do it using install scripts, that's way beyond my capability. It would require knowledge of packaging and scripting that I simply don't have. I am sure others can help pull it together. Right?

morciej avatar Jan 24 '22 03:01 morciej

Another option is adding the entry to https://gitlab.freedesktop.org/xdg/shared-mime-info. That way, distros will know about the MIME type even without TreeSheets installed, and be able to suggest a package to install when user tries to open it.

jtojnar avatar Mar 12 '22 13:03 jtojnar

It might also be nice to officially register a MIME type (likely application/vnd.treesheets) with IANA:

jtojnar avatar Mar 31 '22 01:03 jtojnar