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

Quick Add does not work in flatpak #246

Closed
gwutz opened this issue Feb 24, 2020 · 40 comments
Closed

Quick Add does not work in flatpak #246

gwutz opened this issue Feb 24, 2020 · 40 comments
Labels
Status: 3 - Help Wanted Help is requested from the community to solve this bug or implement this feature.

Comments

@gwutz
Copy link

gwutz commented Feb 24, 2020

Describe the bug
Quick Add Shortcut "CTRL + TAB" should trigger Quick Add to add a item in the inbox. The flatpak variant does not trigger this Quick Add app.

To Reproduce
Steps to reproduce the behavior:

  1. Install via flathub planner 2.2
  2. Setup Shortcut for Quick Add in Planner Settings
  3. Trigger Quick Add

Expected behavior
Quick Add application starts

Desktop (please complete the following information):

  • OS or DE: Gnome
  • Version 3.34
@alainm23 alainm23 added Status: 3 - Help Wanted Help is requested from the community to solve this bug or implement this feature. Priority: Urgent labels Feb 24, 2020
@alainm23 alainm23 pinned this issue Feb 25, 2020
@roypen
Copy link

roypen commented Feb 26, 2020

I've installed Planner 2.2.8 on Fedora 32 using ninja install. Quick-add works without any problem.
Command com.github.alainm23.planner-quick-add launches a quick add window. I can define shortcut directly in the application or in gnome settings -> keyboard shortcuts.
However, this command does not work in flatpak version. Executing flatpak run com.github.alainm23.planner-quick-add
returns:
error: app/com.github.alainm23.planner-quick-add/x86_64/master not installed

I wonder if quick-add shouldn't be installed as a separate flatpak application?

@alainm23
Copy link
Owner

I think it's most likely. I still have some technical issues to solve, for example: my flatpak installation doesn't recognize me "org.gnome.settings-daemon.plugins.media-keys, I'm not sure how to fix this.

@roypen
Copy link

roypen commented Feb 28, 2020

I've also noticed a warning about media keys.
I can confirm that "quick add" works when installed as a separate flatpak application. I didn't build it. I just manually created flatpak app based on original Planner filer. Modified metadata, removed the unnecessary files and created sym link to Planner database and config. flatpak run com.github.alainm23.planner-quick-add executes the application and allows to add new task under a specified project. The problem is when the main application is running in background you won't see newly created tasks on the main Planner window. Only the task counter refreshes. To see tasks added by "quick add" you have to kill background process of main Planner app and run it again. I understand that this is because, as a flatpak, these are separate applications and "quick-add" will not refresh the list of another application. The solution would be to refresh the task list every time the application window is activated.

@alainm23
Copy link
Owner

In the AppCenter version I am using a dbus server to connect the two applications and thus update each time a task is created from QuickAdd.

Do you think that if we reference this dbus server in the flatpak installation file, the two applications can be connected?

@alainm23
Copy link
Owner

@roypen Could you tell me how you did this? I'd be very grateful to you.

@roypen
Copy link

roypen commented Feb 28, 2020

@roypen Could you tell me how you did this? I'd be very grateful to you.
I don't know yet but I will try to figure it out.

@roypen
Copy link

roypen commented Feb 28, 2020

I built a flatpak quick-add application based on the original manifest file. In manifest changed every line containing com.github.alainm23.planner to com.github.alainm23.planner-quick-add.
In "finish-args" section: I modified --metadata=X-DConf path and added
"--talk-name=com.github.alainm23.planner" to allow qick-add to commnicate with the main app.
The code probably contains many unnecessary things for quick-add flatpak app but I didn't focus on it.
Now it seems that quick-add works as it should. Task list refreshes each time I add task in quick-add.
There are two problems:

  1. After installation you have to create a symlink from ~/.var/app/com.github.alainm23.planner-quick-add to ~/.var/app/com.github.alainm23.planner. The apps will share the same .db, config etc.. You can also symlink only database folder or a file to avoid quick-add running in the background. Unfortunately, this solution caused some issues in displaying project names in quick-add window so I made a symlink to the whole folder.
  2. Keyboard shortcut from the main app doesn't work and there is nothing strange about it since the command has changed to: flatpak run com.github.alainm23.planner-quick-add. I defined the application shortcut in Gnome Settings and it works.

@roypen
Copy link

roypen commented Feb 28, 2020

com.github.alainm23.planner-quick-add.txt
I was not able to upload json file so I changed the extension.

@alainm23
Copy link
Owner

Thank you very much, everything works very well, the only thing that worries me is the symbolic links. One solution could be to use our DBus server to get the database information and some dconf settings, but for this to work Planner would have to be running all the time.

@roypen
Copy link

roypen commented Feb 29, 2020

I think most users allow Planner to run in background.
Haven't you consider adding a button in Planner settings (only for the Flathub version) that would install quick-add? It could first create a symlink and then install a quick-add application. I know that this is probably not very optimal/elegant solution. And what if the user wants to install "guick-add" by himself from command line? Quick-add should not be available to the public then(e.g. on the flathub site).
It's just my thoughts but maybe you will find them useful. :)

@nils-asmussen
Copy link

As another workaround the following command seems to open the quick-add window:

flatpak run --command=com.github.alainm23.planner-quick-add --own-name=com.github.alainm23.planner-quick-add com.github.alainm23.planner

@alainm23
Copy link
Owner

@nils-asmussen Thank you very much, that's an incredible solution.
Now, the only problem is how to assign a keyboard shortcut from Flatpak. @bilelmoussaoui maybe you can help us please.

@bilelmoussaoui
Copy link

@nils-asmussen Thank you very much, that's an incredible solution.
Now, the only problem is how to assign a keyboard shortcut from Flatpak. @bilelmoussaoui maybe you can help us please.

Flatpak expects that all the exported files or services (this case DBus) should be prefixed by the app-id. Renaming the Quick Add ID to use something like com.github.alainm23.planner.quick-add should fix it as you do own that.

@alainm23
Copy link
Owner

@bilelmoussaoui thank you very much for your time, I have changed the app-id of Quick Add but when I run Planner I have an error with my service that configures the keyboard shortcuts.

** (com.github.alainm23.planner:2): WARNING **: 15:54:36.510: CustomShortcutSettings.vala:28: Schema "org.gnome.settings-daemon.plugins.media-keys" is not installed on your system.

This service does all the work:
https://github.com/alainm23/planner/blob/master/src/Services/CustomShortcutSettings.vala

@bilelmoussaoui
Copy link

It's normal that you cant access the scheme of org.gnome.settings-daemon.plugins.media-key as it's not available inside the sandbox. If you want to be able to modify system's settings, you need to open a hole in your sandbox for dconf access which should fix the issue for now.

@alainm23
Copy link
Owner

@bilelmoussaoui Thank you very much for your time, I will continue investigating.

@nils-asmussen
Copy link

@alainm23 Would you mind to try if you can set the keyboard shortcut if you start planner with the following command?

flatpak run --talk-name=org.gnome.settings-daemon.plugins.media-keys com.github.alainm23.planner

On the system I am currently using, the dbus namespace seems to have a different name, org.gnome.SettingsDaemon.MediaKeys. This unfortunately prevents me from trying it myself.

@alainm23
Copy link
Owner

@nils-asmussen I am getting the same warning.

@bilelmoussaoui
Copy link

@alainm23
Copy link
Owner

@bilelmoussaoui Thank you very much, I have changed the permissions of my application to:

 "--filesystem=xdg-run/dconf",
 "--filesystem=~/.config/dconf:ro",
 "--talk-name=ca.desrt.dconf",
 "--env=DCONF_USER_CONFIG_DIR=.config/dconf"

I have noticed that I can now access the system's dconf settings but I still don't have access to
org.gnome.settings-daemon.plugins.media-keys

Do you think it is necessary to add one more permit?

@bilelmoussaoui
Copy link

@bilelmoussaoui Thank you very much, I have changed the permissions of my application to:

 "--filesystem=xdg-run/dconf",
 "--filesystem=~/.config/dconf:ro",
 "--talk-name=ca.desrt.dconf",
 "--env=DCONF_USER_CONFIG_DIR=.config/dconf"

I have noticed that I can now access the system's dconf settings but I still don't have access to
org.gnome.settings-daemon.plugins.media-keys

Do you think it is necessary to add one more permit?

I'm not sure what you mean by "you don't have access", access to modifying the scheme?

@alainm23
Copy link
Owner

I'm not sure what you mean by "you don't have access", access to modifying the scheme?

Yes I am getting the same error,

** (com.github.alainm23.planner:2): WARNING **: 15:54:36.510: CustomShortcutSettings.vala:28: Schema "org.gnome.settings-daemon.plugins.media-keys" is not installed on your system.

@nils-asmussen
Copy link

@alainm23 Thank you for testing the flatpak option and for your work on this amazing program!

On my "main" system the gsettings schema org.gnome.settings-daemon.plugins.media-keys exists as a file in the folder /usr/share/glib-2.0/schemas. The files does not appear in the flatpak environment (flatpak run --command=sh ...).
Could that be related to the reason why
gsettings list-schemas | grep gnome.s
does not list the settings daemon, and ultimately the media keys do not work?
(Just a guess, as there are lots of things for me to learn about dbus and gsettings...)

@nils-asmussen
Copy link

Summary

I can now confirm that the schema needs to be installed in /usr/share/glib-2.0/schemas.
The conclusions section of this post summarizes what I think needs to be done to resolve this issue.

Details of the test

As a dirty hack to check if it works, I copied the glib-2.0 folder to my home folder and started the flatpak with access to the copy,

cp -r /usr/share/glib-2.0 ~
flatpak run --command=sh --filesystem=~/glib-2.0 com.github.alainm23.planner

Now, in the shell inside flatpak, I make the schemas in ~/glib-2.0 available to glib/gsettings, by adding the home directory to XDG_DATA_DIRS,

export XDG_DATA_DIRS="$XDG_DATA_DIRS:$HOME"

and I can actually see the schema org.gnome.settings-daemon.plugins.media-keys in gsettings:

gsettings list-schemas | grep org.gnome.settings-daemon

If I start com.github.alainm23.planner, I can see in the system settings that a custom keyboard shortcut has been added for com.github.alainm23.planner.quick-add (closing and reopening the settings might be necessary for the changes to appear).

Note: The keyboard shortcut runs the command com.github.alainm23.planner.quick-add, which does not exist if planner is installed via flatpak. Therefore simply pressing the keys still does not open the quick-add dialog, even though the media key has been successfully added.

Conclusions

  • For flatpak installations, the command that is added to the Media Keys needs to be changed to
flatpak run --command=com.github.alainm23.planner.quick-add com.github.alainm23.planner
  • The schema org.gnome.settings-daemon.plugins.media-keys needs to be installed inside the flatpak. Note: The gnome-settings-daemon sources (https://github.com/GNOME/gnome-settings-daemon) contain the schemas in the data folder. Maybe installing that package inside the flatpak helps?

@wingej0
Copy link

wingej0 commented May 13, 2020

I've been following this for awhile. I love this program, but not having the quick-add feature in the flatpak was problematic. I don't know if it helps, but I have added (from the comment above)

flatpak run --command=com.github.alainm23.planner.quick-add com.github.alainm23.planner

to my keyboard shortcuts on Pop!_OS, and the quick add is working perfectly. It's not the most elegant solution, but I've been using it for a few days without any problems.

Thank you for a wonderful program.

@alainm23
Copy link
Owner

Thank you all very much to everyone to help.
Researching the problem I think Flatpak does not support configuring keyboard shortcuts yet. For this reason and as AppCenter will start using flatpak the only option is to configure keyboard shortcuts manually.

I will make some changes in the Quick Add preferences indicating the steps to configure the keyboard shortcuts in the system 😔️.

@bilelmoussaoui
Copy link

Thank you all very much to everyone to help.
Researching the problem I think Flatpak does not support configuring keyboard shortcuts yet. For this reason and as AppCenter will start using flatpak the only option is to configure keyboard shortcuts manually.

I will make some changes in the Quick Add preferences indicating the steps to configure the keyboard shortcuts in the system pensive.

I just looked at the issue again, and indeed. Flatpak limits the access to the system by default to avoid malicious applications doing random things on the system. I don't think there will be a way to do this automatically like apps used to do so, the best way to handle this would be a portal that allows an app to set a specific shortcut. Shipping the packages that ships the schema doesn't make sense as you will be able to change the setting, inside the sandbox and won't matter for your system at all.

@nils-asmussen
Copy link

My previous post seems to have been missed. There I describe how one can make this feature work.

@nils-asmussen
Copy link

Maybe not the cleanest, but the simplest way is to add the following to the manifest (I added it as last module before planner):

    {
      "name": "media-keys",
      "buildsystem": "simple",
      "build-commands": [
          "install -D data/org.gnome.settings-daemon.plugins.media-keys.gschema.xml.in /app/share/glib-2.0/schemas/org.gnome.settings-daemon.plugins.media-keys.gschema.xml",
          "sed -i -e 's/@GETTEXT_PACKAGE@/gnome-settings-daemon/g' /app/share/glib-2.0/schemas/org.gnome.settings-daemon.plugins.media-keys.gschema.xml"
      ],
      "sources" : [
      {
          "type" : "archive",
          "url" : "https://github.com/GNOME/gnome-settings-daemon/archive/GNOME_SETTINGS_DAEMON_3_36_1.tar.gz",
          "sha256" : "e345411f79b4a1175349e144cc772c7a9eb7ab9ae3a542a73609bee471b72748"
      }
      ]
    },

@alainm23
Copy link
Owner

@nils-asmussen I can confirm that the keyboard shortcut settings work on flatpak and elementary OS. I will still do some tests on other distributions.

@alainm23 alainm23 reopened this May 13, 2020
@alainm23
Copy link
Owner

alainm23 commented May 13, 2020

I confirm Quick Add works on Pop! _OS 19.10 🎉️🎉️🎉️

image

@4jNsY6fCVqZv
Copy link

@alainm23 Is the black bar part of the window decoration? The input field also looks a bit cut off.

Flatpak limits the access to the system by default to avoid malicious applications doing random things on the system.

@bilelmoussaoui So are there currently any security concerns about including Quick Add in a flatpak?

@bilelmoussaoui
Copy link

@alainm23 Is the black bar part of the window decoration? The input field also looks a bit cut off.

Flatpak limits the access to the system by default to avoid malicious applications doing random things on the system.

@bilelmoussaoui So are there currently any security concerns about including Quick Add in a flatpak?

I'm no security expert, but Flatpak isn't designed for hackish solutions as this. Apps used to do whatever they wanted at host level and they really shouldn't.

It's a a hackish solution for now, but shouldn't be taken as "the solution".

@4jNsY6fCVqZv
Copy link

4jNsY6fCVqZv commented May 14, 2020

It's a a hackish solution for now, but shouldn't be taken as "the solution".

@alainm23 Perhaps the code can be annotated to reflect this?

@bxff
Copy link

bxff commented Jun 7, 2021

I am still having this problem, my version: 2.7
I haven't tried any workarounds yet.

@alainm23

@bxff
Copy link

bxff commented Jun 8, 2021

Update: Running flatpak run --command=com.github.alainm23.planner.quick-add com.github.alainm23.planner runs the quick add option, so I have created a shortcut to run the command. I also followed the issue and I am guessing this can only be fixed per distro, and my distro is not fixed. For your information I am using Zorin 16.

@cassidyjames
Copy link

This seems like it is related to the autostart permission; I wonder if the background portal can/should be extended to handle launching on keyboard shortcuts, or if it would be best for a new portal. 🤔

@davelbit
Copy link

davelbit commented Jan 4, 2023

Has there been any progress on the quick-add function for the flatpak version?

@alainm23
Copy link
Owner

alainm23 commented Jan 4, 2023

Quick Add is under construction, but it will most likely not be automatic as Panner 2 did, it will probably require additional configuration by the user.

@cassidyjames
Copy link

@alainm23 also note that Flatpak/xdg-portals now support a global shortcuts portal for exactly this sort of thing. 😄 Based on an issue I opened inspired by Planner: flatpak/xdg-desktop-portal#624

It would probably be the best way to implement this in the proper way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: 3 - Help Wanted Help is requested from the community to solve this bug or implement this feature.
Projects
None yet
Development

No branches or pull requests

10 participants