Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add information on mimetypes #115

Open
allanday opened this issue Apr 13, 2018 · 11 comments
Open

Add information on mimetypes #115

allanday opened this issue Apr 13, 2018 · 11 comments

Comments

@allanday
Copy link
Collaborator

Mime types ought to be listed in conventions.rst. These files need to be named with the app ID.

See flatpak/flatpak#1572 for background.

@hadess
Copy link
Contributor

hadess commented Mar 7, 2019

flatpak/flatpak@3e9bc8b
has a list of restrictions it applies to exported mime-types, to avoid applications from taking over file associations.

@bryce-carson
Copy link

I've looked at both of those links. There's nothing documented about where mimetypes should be installed, specifically. The XDG guidelines can't be followed in this case, because of this case:

/usr/share/icons/hicolor/scalable/mimetypes/aMIMEicon.svg can't be used, /usr/ is read-only.
/app/ . . . /mimetypes/aMIMEicon.svg causes very strange problems:

  1. The application icon in /app/share/icons/hicolor/scalable/apps/anApplicationIcon.svg isn't used anymore; the desktop glob fails apparently
  2. The mimetype icon in /app/share/icons/hicolor/scalable/mimetypes/aMIMEicon.svg is applied to the application launcher
  3. Files of the new mimetype, which is properly applied to files with the glob pattern aren't given the icon.

The documentation should be as verbose and thorough regarding mimetypes and their icons as it is with desktop files and application icons.

@TingPing
Copy link
Member

TingPing commented May 2, 2021

Files of the new mimetype, which is properly applied to files with the glob pattern aren't given the icon.

Commonly its just that you forget to rename the contents of the mimetype file while renaming the actual icon.

Honestly I think flatpak gaining a new property to rename these for projects would be really nice.

@bryce-carson
Copy link

bryce-carson commented May 2, 2021 via email

@bryce-carson
Copy link

For the sake of clarity, here's the manifest I have right now. Where the documentation says that desktop entry files and application icons should be installed in FreeDesktop-spec subdirectories of /app/share, I make the assumption that mimetype files should be installed similarly, and that mimetype icons can be placed in the /mimetypes/ subdirectory of /hicolor/scalable.

Making the documentation verbose won't hurt.

app-id: org.messerlab.slimgui
runtime: org.kde.Platform
runtime-version: '5.15'
sdk: org.kde.Sdk
finish-args:
  - --socket=wayland
  - --socket=x11
  - --share=ipc
  - --device=dri
  - --socket=pulseaudio
  - --share=network
  - --filesystem=host
  - --talk-name=com.canonical.AppMenu.Registrar # required for global menu
  - --talk-name=org.freedesktop.Flatpak # allows spawning processes on the host via flatpak-spawn --host
  - --env=PKG_CONFIG_PATH=/app/lib/pkgconfig:/app/share/pkgconfig
command: SLiMgui
modules:
  - name: SLiMgui
    builddir: true
    buildsystem: cmake
    config-opts:
      - -DBUILD_SLIMGUI=ON
      - --debug-output
    sources:
      - type: git
        url: https://github.com/MesserLab/SLiM.git
        tag: "v3.6"
        commit: 978622ebc1a0326f91d1cee35fd91e1e0f4e0c92
    post-install:
      # Colourful and Symbolic Application Icons
      - sed -i '69,166 s/"fill:#[[:alnum:]]*"/"fill:#ffffff"/' ../QtSLiM/icons/AppIcon16.svg
      - sed -i '62,68 d' ../QtSLiM/icons/AppIcon16.svg
      - install --mode=0644 -D --no-target-directory ../QtSLiM/icons/AppIcon64.svg /app/share/icons/hicolor/scalable/apps/org.messerlab.slimgui.svg
      - install --mode=0644 -D --no-target-directory ../QtSLiM/icons/AppIcon16.svg /app/share/icons/hicolor/symbolic/apps/org.messerlab.slimgui-symbolic.svg
      
      # slim Mimetype
      # Line 6 in original org.messerlab.slimgui-mime.xml
      # <generic-icon name="/usr/share/icons/hicolor/scalable/mimetypes/text-slim.svg"/>
      - sed -i '6 s,usr,app,' ../org.messerlab.slimgui-mime.xml
      - sed -i '6 s,mimetypes/text-slim.svg,mimetypes/org.messerlab.slimgui-text-slim.svg,' ../org.messerlab.slimgui-mime.xml 
      - install --mode=0644 -D --no-target-directory ../org.messerlab.slimgui-mime.xml /app/share/mime/packages/org.messerlab.slimgui-mime.xml
      - install --mode=0644 -D --no-target-directory ../QtSLiM/icons/DocIcon.svg /app/extra/export/share/icons/hicolor/scalable/mimetypes/org.messerlab.slimgui-text-slim.svg
      
      # Desktop Entry and Appstream XMLs
      - desktop-file-edit --remove-key=Exec ../org.messerlab.slimgui.desktop
      - desktop-file-edit --set-key=Exec --set-value='SLiMgui %f' ../org.messerlab.slimgui.desktop
      - desktop-file-install --mode=0644 --dir=/app/share/applications/ ../org.messerlab.slimgui.desktop
      - appstream-util validate-relax ../org.messerlab.slimgui.appdata.xml
      - install --mode=0644 -D ../org.messerlab.slimgui.appdata.xml --target-directory /app/share/metainfo/

@TingPing
Copy link
Member

TingPing commented May 3, 2021

I have text-slim.svg and in the XML.

It must be prefixed with $APP_ID. Like org.messerlab.slimgui.text-slim.svg.

@TingPing
Copy link
Member

TingPing commented May 3, 2021

  # <generic-icon name="/usr/share/icons/hicolor/scalable/mimetypes/text-slim.svg"/>
 - sed -i '6 s,usr,app,' ../org.messerlab.slimgui-mime.xml

Also anything with a full path is probably just broken. Things should rely on icon theme names.

@bryce-carson
Copy link

bryce-carson commented May 3, 2021 via email

@bryce-carson
Copy link

The mime XML now reads:

<generic-icon name="org.messerlab.slimgui.text-slim.svg"/>

and the icon is named org.messerlab.slimgui.text-slim.svg. It is till not working; I used tweaks and tried using the Hicolor icon theme and others.
Placing the icon in either of /app/share/mime/packages or /app/share/icons/hicolor/scalable/mimetypes/ did not work. The system icon for text files is still applied to the icon, despite the mimetype being properly registered and recognized for the filetype.

What is the exact place I should store the mimetype icon, such that it is exported to the correct location and applied? Note that I am manipulating and installing this icon and the mimetype itself in post-install:, if that may be relevant.

@TingPing
Copy link
Member

TingPing commented May 5, 2021

The path seems fine. You can see the exact files exported in $BUILDDIR/export (where BUILDDIR is what you passed to flatpak-builder).

@bryce-carson
Copy link

I'll note here that separating the prefix and icon name with a 'Full Stop' (.; Unicode U+002E; I like to be specific to remove ambiguity 🤷🏻) did not work; using a Hyphen-minus (-; Unicode U+002D) did work. I looked at the manifests for codeblocks and turtleart, both of which used a hyphen. A hyphen separator worked, and using generic-icon ensures that the icon is available regardless of the users' icon theme.

      # slim Mimetype
      - sed -i '6 s,<generic-icon name="/usr/share/icons/hicolor/scalable/mimetypes/text-slim.svg"/>,<generic-icon name="org.messerlab.slimgui-text-slim"/>,' ../org.messerlab.slimgui-mime.xml 
      - install --mode=0644 -D --no-target-directory ../org.messerlab.slimgui-mime.xml /app/share/mime/packages/org.messerlab.slimgui-mime.xml
      - install --mode=0644 -D --no-target-directory ../QtSLiM/icons/DocIcon.svg /app/share/icons/hicolor/scalable/mimetypes/org.messerlab.slimgui-text-slim.svg

This only worked when installing the mime icon to the path above, the earlier path I referred to, /app/extra/export/share/icons/hicolor/scalable/mimetypes/, did not seem to work.

In my opinion, a paragraph on mimetype icons should be included in the flatpak-docs. I would write one up and submit a pull request, but I'm not confident in my knowledge when it comes to Flatpak, not at all.

Thanks for your help, regardless, @TingPing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants