flatpak-docs
flatpak-docs copied to clipboard
Add information on mimetypes
Mime types ought to be listed in conventions.rst. These files need to be named with the app ID.
See https://github.com/flatpak/flatpak/issues/1572 for background.
https://github.com/flatpak/flatpak/commit/3e9bc8ba7a2ef6333b2ee381db4f32248f764a44 has a list of restrictions it applies to exported mime-types, to avoid applications from taking over file associations.
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:
- The application icon in /app/share/icons/hicolor/scalable/apps/anApplicationIcon.svg isn't used anymore; the desktop glob fails apparently
- The mimetype icon in /app/share/icons/hicolor/scalable/mimetypes/aMIMEicon.svg is applied to the application launcher
- 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.
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.
I have text-slim.svg and
It also doesn't explain why Flatpak decided to use the mimetype icon for the application once one was present.
Would you mind sharing a worked example? I've honestly spent six hours trying to determine the correct way to do it.
On Sun., May 2, 2021, 9:55 a.m. Patrick, @.***> wrote:
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.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/flatpak/flatpak-docs/issues/115#issuecomment-830830740, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMMRAZNO3OGZKI3VV64WQN3TLVYY3ANCNFSM4E2M7RLA .
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/
I have text-slim.svg and
in the XML.
It must be prefixed with $APP_ID. Like org.messerlab.slimgui.text-slim.svg.
# <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.
Thanks! I'll change from: org.messerlab.slimgui-text-slim.svg, to org.messerlab.slimgui.text-slim.svg.
I'll test the change and let you know if I have any more problems.
Regards,
Bryce Carson.
On Mon., May 3, 2021, 12:10 p.m. Patrick, @.***> wrote:
I have text-slim.svg and in the XML.
It must be prefixed with $APP_ID. Like org.messerlab.slimgui.text-slim.svg .
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/flatpak/flatpak-docs/issues/115#issuecomment-831435295, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMMRAZNOW5E3VETBOUVZLWTTL3RKVANCNFSM4E2M7RLA .
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.
The path seems fine. You can see the exact files exported in $BUILDDIR/export (where BUILDDIR is what you passed to flatpak-builder).
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.