flathub / shared-modules

Common Flatpak modules that can be used as a git submodule
116 stars 89 forks source link

why no libayatana-appindicator3? #223

Closed sgehrman closed 1 year ago

sgehrman commented 1 year ago

I'm building a flutter app, it uses libayatana-appindicator3 if it exists on my build machine, but I don't see that in here.

Is that simple to fix? I know very little about this, send hints.

Just spent a week trying to get snap working and it was a total disaster. I'm hoping flatpak is easier, but these submodules look super complex and would require deep linux knowledge. I would have no idea how to build these build steps.

Ideally I would just want to do an 'apt install libayatana-appindicator3" in my flatpak and be done with it. Is there anything simple like this? figuring out how to build the code and getting the hashes and all the steps seems near impossible for the non linux geek.

Also, adding a git submodule is something I would rather not do. I want to keep my project simple and don't want to complicate it just for an 'installer'. If there's a way to avoid that, that would be good.

orowith2os commented 1 year ago

Adding a shared module from here isn't very hard, just git submodule add this repo and follow the instructions in the main README. It wouldn't complicate a project much, just adds a folder you link to.

Alternatively, why can't your app just add the normal libappindicator module? If it can't do that, you can more or less copy-paste how WhatsAppForLinux uses libayatana-appindicator3:

https://github.com/flathub/com.github.eneshecan.WhatsAppForLinux/blob/9255628082f995783d3f625685b55eeb72661d29/com.github.eneshecan.WhatsAppForLinux.yml#L104

A6GibKm commented 1 year ago

It would be interesting to have a list of flatpaks that use this module.

orowith2os commented 1 year ago

It would be interesting to have a list of flatpaks that use this module.

Doing a quick index of Flathub using GitHub's search function, it's only WhatsAppForLinux that uses it.

https://github.com/search?q=org%3Aflathub+libayatana&type=code

A6GibKm commented 1 year ago

If it is used by only one project with maybe a second on its way then I don't think it is reason enough for having a shared-module. Those projects can just add it to the manifest.

TingPing commented 1 year ago

The reason I packaged appindicator here and not ayatana is because they are different libraries with different APIs.

Appindicator also being unmaintained meant it is hell to build and required patches, hacks, etc.

Hopefully Ayatana is easier to build but if a lot of projects need it then it could be added here too.

TingPing commented 1 year ago

@sgehrman Also, you do have to learn how to build projects, on a basic level, to effectively maintain a flatpak. Nothing will change that.

sgehrman commented 1 year ago

Thanks for the info.

Tried to add

  - name: ayatana-ido
    buildsystem: cmake-ninja
    sources:
      - type: git
        url: https://github.com/AyatanaIndicators/ayatana-ido.git
        tag: 0.9.2

but getting:

CMake Error at /usr/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find Vala (missing: VALA_COMPILER)
Call Stack (most recent call first):
  /usr/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  cmake/FindVala.cmake:52 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  src/CMakeLists.txt:164 (find_package)

I tried installing everything vala that I could find, but doesn't work. I'm on Debian.

I'm also confused about which platform I should use. I'm using org.freedesktop.Platform, but what's app is using org.gnome.Platform

How do I know which to use? What if someone isn't using gnome? I don't know how this affects other distros.

orowith2os commented 1 year ago

Please attach the full flatpak manifest, the markdown formatting here doesn't really help.

sgehrman commented 1 year ago

I copied that from whatsapp, but here it is (so far)

Yaml ```yaml app-id: com.cocoatech.Driftwood runtime: org.freedesktop.Platform runtime-version: '22.08' sdk: org.freedesktop.Sdk command: driftwood separate-locales: false finish-args: - --share=ipc - --socket=fallback-x11 - --socket=wayland - --device=dri - --share=network modules: - name: driftwood buildsystem: simple only-arches: - x86_64 build-commands: - mkdir -p Driftwood - tar -xf Driftwood-Linux-Portable.tar.gz -C Driftwood - cp -r Driftwood /app/ - chmod +x /app/Driftwood/driftwood - mkdir -p /app/bin - ln -s /app/Driftwood/driftwood /app/bin/driftwood - mkdir -p /app/share/metainfo - cp -r com.cocoatech.Driftwood.metainfo.xml /app/share/metainfo/ - mkdir -p /app/share/icons/hicolor/scalable/apps - cp -r icon.svg /app/share/icons/hicolor/scalable/apps/com.cocoatech.Driftwood.svg - mkdir -p /app/share/applications - cp -r com.cocoatech.Driftwood.desktop /app/share/applications/ - mkdir -p /app/share/appdata - cp -r com.cocoatech.Driftwood.metainfo.xml /app/share/appdata/ sources: - type: file path: com.cocoatech.Driftwood.metainfo.xml - type: file path: com.cocoatech.Driftwood.desktop - type: file path: icon.svg - type: file path: Driftwood-Linux-Portable.tar.gz - name: ayatana-ido buildsystem: cmake-ninja sources: - type: git url: https://github.com/AyatanaIndicators/ayatana-ido.git tag: 0.9.2 ```
hfiguiere commented 1 year ago

you probably need to disable vala when building it.

vala is part of the GNOME runtime but if you don't need it then you shouldn't be.

sgehrman commented 1 year ago

should I use gnome? I have no idea about linux distros and making sure my app will run on most of them.

How do I disable it?

my dev machine: $ vapigen --version Vala API Generator 0.48.17 $ vala --version Vala 0.48.17

orowith2os commented 1 year ago

You should use the org.gnome.Platform and org.gnome.Sdk rather than the freedesktop one; use the WhatsAppForLinux manifest as a reference: https://github.com/flathub/com.github.eneshecan.WhatsAppForLinux/blob/master/com.github.eneshecan.WhatsAppForLinux.yml

And be sure to change the runtime-version to 43, as that's the latest.

TingPing commented 1 year ago

How do I know which to use? What if someone isn't using gnome? I don't know how this affects other distros.

They all work on any distro. The difference is bundled libraries. Some details are here: https://docs.flatpak.org/en/latest/available-runtimes.html

hfiguiere commented 1 year ago

Not if you don't need it.

File a bug with that package as it seems to find_package(Vala REQUIRED QUIET) but this is unreasonable requirement.

TingPing commented 1 year ago

you probably need to disable vala when building it.

It looks like they expose no options to disable features. Disappointing.

I tried installing everything vala that I could find, but doesn't work. I'm on Debian.

@sgehrman Flatpak is a sandbox. Nothing you install on your host matters or does anything*.

sgehrman commented 1 year ago

ok, it built but I don't see the app indicator.

$ flatpak run com.cocoatech.Driftwood Gtk-Message: 15:39:12.063: Failed to load module "canberra-gtk-module" Gtk-Message: 15:39:12.063: Failed to load module "canberra-gtk-module"

(driftwood:2): CRITICAL : 15:39:12.358: Failed to read XDG desktop portal settings: GDBus.Error:org.freedesktop.portal.Error.NotFound: Requested setting not found

(driftwood:2): CRITICAL : 15:39:12.359: Failed to read XDG desktop portal settings: GDBus.Error:org.freedesktop.portal.Error.NotFound: Requested setting not found

Yaml ``` app-id: com.cocoatech.Driftwood runtime: org.gnome.Platform runtime-version: '43' sdk: org.gnome.Sdk command: driftwood separate-locales: false finish-args: - --share=ipc - --socket=fallback-x11 - --socket=wayland - --device=dri - --share=network modules: - name: driftwood buildsystem: simple only-arches: - x86_64 build-commands: - mkdir -p Driftwood - tar -xf Driftwood-Linux-Portable.tar.gz -C Driftwood - cp -r Driftwood /app/ - chmod +x /app/Driftwood/driftwood - mkdir -p /app/bin - ln -s /app/Driftwood/driftwood /app/bin/driftwood - mkdir -p /app/share/metainfo - cp -r com.cocoatech.Driftwood.metainfo.xml /app/share/metainfo/ - mkdir -p /app/share/icons/hicolor/scalable/apps - cp -r icon.svg /app/share/icons/hicolor/scalable/apps/com.cocoatech.Driftwood.svg - mkdir -p /app/share/applications - cp -r com.cocoatech.Driftwood.desktop /app/share/applications/ - mkdir -p /app/share/appdata - cp -r com.cocoatech.Driftwood.metainfo.xml /app/share/appdata/ sources: - type: file path: com.cocoatech.Driftwood.metainfo.xml - type: file path: com.cocoatech.Driftwood.desktop - type: file path: icon.svg - type: file path: Driftwood-Linux-Portable.tar.gz - name: intltool cleanup: - '*' sources: - type: archive url: https://launchpad.net/intltool/trunk/0.51.0/+download/intltool-0.51.0.tar.gz sha256: 67c74d94196b153b774ab9f89b2fa6c6ba79352407037c8c14d5aeb334e959cd - name: ayatana-ido buildsystem: cmake-ninja sources: - type: git url: https://github.com/AyatanaIndicators/ayatana-ido.git tag: 0.9.1 - name: libayatana-indicator buildsystem: cmake-ninja sources: - type: git url: https://github.com/AyatanaIndicators/libayatana-indicator.git tag: 0.9.2 - name: libdbusmenu-gtk3 buildsystem: autotools build-options: cflags: -Wno-error config-opts: - --with-gtk=3 - --disable-dumper - --disable-static - --enable-tests - --disable-gtk-doc - --enable-introspection=no - --disable-vala sources: - type: archive url: https://launchpad.net/libdbusmenu/16.04/16.04.0/+download/libdbusmenu-16.04.0.tar.gz sha256: b9cc4a2acd74509435892823607d966d424bd9ad5d0b00938f27240a1bfa878a - name: libayatana-appindicator buildsystem: cmake-ninja config-opts: - -DENABLE_BINDINGS_MONO=NO - -DENABLE_BINDINGS_VALA=NO sources: - type: git url: https://github.com/AyatanaIndicators/libayatana-appindicator.git tag: 0.5.90 ```
sgehrman commented 1 year ago

oh, I got it kind of working by adding some finish args.

But the icon is '...' which is weird.

sgehrman commented 1 year ago

gnome-shell-screenshot-Y0M3W1

sgehrman commented 1 year ago
Dec 10 15:55:28 5950x ubuntu-appindicators@ubuntu.com[3237]: unable to update icon for fWoDQCmZt
Dec 10 15:55:28 5950x ubuntu-appindicators@ubuntu.com[3237]: fWoDQCmZt, Impossible to read image info from path '/app/Driftwood/data/flutter_assets/assets/images/appIcon.png': GdkPixbuf.PixbufError: Failed to recognize image>
Dec 10 15:55:28 5950x gnome-shell[3237]: Window manager warning: Buggy client sent a _NET_ACTIVE_WINDOW message with a timestamp of 0 for 0x4600003
Dec 10 15:55:28 5950x ubuntu-appindicators@ubuntu.com[3237]: unable to update icon for fWoDQCmZt
Dec 10 15:55:28 5950x ubuntu-appindicators@ubuntu.com[3237]: fWoDQCmZt, Impossible to read image info from path '/app/Driftwood/data/flutter_assets/assets/images/appIcon.png': GdkPixbuf.PixbufError: Failed to recognize image>
TingPing commented 1 year ago

All of these permissions are unrelated and many probably wrong.

You need to ensure your icon is properly named (prefixed by your app-id), installed to the correct directories, and referenced by that name. You cannot load by file path as you are trying.

sgehrman commented 1 year ago

The icon works fine on a normal build, but not in this flatpak build.
Any idea why not?

TingPing commented 1 year ago

Because flatpak sandboxes applications. This provides security, portability, and prevents conflicts with other packages.

sgehrman commented 1 year ago

The image is part of my built app.

TingPing commented 1 year ago

Yes but the system cannot see your apps files. You have to name them and place them in the correct icons directory for the system to access them.

sgehrman commented 1 year ago

got it, let me think about this. thanks. Is there a recommended icons directory to put this in? Docs on how to do this?

TingPing commented 1 year ago

$PREFIX/share/icons/hicolor/$SIZE/apps/$APP_ID-anything.png

Where $PREFIX is /app in flatpak. $SIZE is like 32x32 (there are specific size options), and $APP_ID would be org.example.App in your flatpak manifest.

TingPing commented 1 year ago

https://docs.flatpak.org/en/latest/conventions.html#application-icons

sgehrman commented 1 year ago

Thanks, I think I can get it working. One thing I noticed:

// running on flatpak my apps data is written here: /home/steve/.var/app/com.cocoatech.Driftwood/data/driftwood

// running normally it's here /home/steve/.local/share/re.distantfutu.dashboard

Is there a filesystem permission to get that to work the same?

sgehrman commented 1 year ago

And is there a way in my code to detect the sandbox?

if (runningInSandbox) { do something } else {}

TingPing commented 1 year ago

@sgehrman You can read the XDG_DATA_HOME env var to get that path, correct in both cases.

orowith2os commented 1 year ago

Thanks, I think I can get it working. One thing I noticed:

// running on flatpak my apps data is written here: /home/steve/.var/app/com.cocoatech.Driftwood/data/driftwood

// running normally it's here /home/steve/.local/share/re.distantfutu.dashboard

Is there a filesystem permission to get that to work the same?

Don't; trying to drag configurations from native packages into a flatpak isn't suggested, and can break apps. The flatpak having its own config directories also helps for security reasons.

To detect a flatpak env, check the root directory for .flatpak-info.

sgehrman commented 1 year ago

Thanks, I think it's all working. Will post to flathub soon.
It would be nice if you did add libayatana-appindicator3 just since it's suppose to be maintained and newer.

orowith2os commented 1 year ago

Thanks, I think it's all working. Will post to flathub soon. It would be nice if you did add libayatana-appindicator3 just since it's suppose to be maintained and newer.

Maybe if there's more demand for it in the future, currently Flathub only has one app using it. (see https://github.com/flathub/shared-modules/issues/223#issuecomment-1345389128)

orowith2os commented 1 year ago

@TingPing is it safe to close this issue as not planned?

sgehrman commented 1 year ago

yeah, but one last problem. I"m putting my tar.gz on github releases, but can't get it working.

getting: gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now

I'm trying to copy AppFlowy, but it doesn't work.

modules:
  - name: driftwood
    buildsystem: simple
    only-arches:
      - x86_64
    build-commands:
      # - mkdir -p Driftwood
      # - tar -xf Driftwood-Linux-Portable.tar.gz -C Driftwood
      - cp -r bundle /app/Driftwood
      - chmod +x /app/Driftwood/driftwood
      - mkdir -p /app/bin
      - ln -s /app/Driftwood/driftwood /app/bin/driftwood
      - mkdir -p /app/share/metainfo
      - cp -r com.cocoatech.Driftwood.metainfo.xml /app/share/metainfo/
      - mkdir -p /app/share/icons/hicolor/scalable/apps
      - cp -r icon.svg /app/share/icons/hicolor/scalable/apps/com.cocoatech.Driftwood.svg
      - mkdir -p /app/share/applications
      - cp -r com.cocoatech.Driftwood.desktop /app/share/applications/
      - mkdir -p /app/share/appdata
      - cp -r com.cocoatech.Driftwood.metainfo.xml /app/share/appdata/
    sources:
      - type: archive
        url: https://github.com/sgehrman/flatpak-assets/releases/download/v1.0.0-beta/Driftwood-Linux-Portable.tar.gz
        sha256: 5a78ecd966768e39e0fd11439474cb340d35a438643671a074341373a10f32fe
        dest: bundle
Downloading sources
Downloading https://github.com/sgehrman/flatpak-assets/releases/download/v1.0.0-beta/Driftwood-Linux-Portable.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 59.4M  100 59.4M    0     0  8642k      0  0:00:07  0:00:07 --:--:-- 9656k
Downloading https://launchpad.net/intltool/trunk/0.51.0/+download/intltool-0.51.0.tar.gz
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  158k  100  158k    0     0  75271      0  0:00:02  0:00:02 --:--:--  245k
Initialized empty Git repository in /home/steve/Documents/GitHub/dfc/dashboard/.flatpak-builder/git/https_github.com_AyatanaIndicators_ayatana-ido.git-0EITW1/
Fetching git repo https://github.com/AyatanaIndicators/ayatana-ido.git, ref refs/tags/0.9.2
remote: Enumerating objects: 94, done.
remote: Counting objects: 100% (94/94), done.
remote: Compressing objects: 100% (79/79), done.
remote: Total 94 (delta 19), reused 36 (delta 7), pack-reused 0
Unpacking objects: 100% (94/94), 144.30 KiB | 978.00 KiB/s, done.
From https://github.com/AyatanaIndicators/ayatana-ido
 * [new tag]         0.9.2      -> 0.9.2
Initialized empty Git repository in /home/steve/Documents/GitHub/dfc/dashboard/.flatpak-builder/git/https_github.com_AyatanaIndicators_libayatana-indicator.git-PRI4W1/
Fetching git repo https://github.com/AyatanaIndicators/libayatana-indicator.git, ref refs/tags/0.9.3
remote: Enumerating objects: 97, done.
remote: Counting objects: 100% (97/97), done.
remote: Compressing objects: 100% (83/83), done.
remote: Total 97 (delta 24), reused 45 (delta 7), pack-reused 0
Unpacking objects: 100% (97/97), 164.48 KiB | 1.07 MiB/s, done.
From https://github.com/AyatanaIndicators/libayatana-indicator
 * [new tag]         0.9.3      -> 0.9.3
Downloading https://launchpad.net/libdbusmenu/16.04/16.04.0/+download/libdbusmenu-16.04.0.tar.gz
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  742k  100  742k    0     0   895k      0 --:--:-- --:--:-- --:--:-- 1851k
Initialized empty Git repository in /home/steve/Documents/GitHub/dfc/dashboard/.flatpak-builder/git/https_github.com_AyatanaIndicators_libayatana-appindicator.git-9B9XW1/
Fetching git repo https://github.com/AyatanaIndicators/libayatana-appindicator.git, ref refs/tags/0.5.91
remote: Enumerating objects: 115, done.
remote: Counting objects: 100% (115/115), done.
remote: Compressing objects: 100% (94/94), done.
remote: Total 115 (delta 18), reused 58 (delta 10), pack-reused 0
Receiving objects: 100% (115/115), 172.56 KiB | 2.30 MiB/s, done.
Resolving deltas: 100% (18/18), done.
From https://github.com/AyatanaIndicators/libayatana-appindicator
 * [new tag]         0.5.91     -> 0.5.91
Initializing build dir
Committing stage init to cache
Starting build of com.cocoatech.Driftwood
========================================================================
Building module driftwood in /home/steve/Documents/GitHub/dfc/dashboard/.flatpak-builder/build/driftwood-1
========================================================================

gzip: stdin: not in gzip format
tar: Child returned status 1
sgehrman commented 1 year ago

I figured it out. I copied the instructions to make a flutter app here: https://github.com/Merrit/flutter_flatpak_example

But the tar command is incorrect. It works now.