Nextcloud-client service unable to open browser via XDG

Hi guys,

I’m encountering an issue with a custom service I’ve created to launch nextcloud-client on startup. The problem seems to be related to XDG functionality when the client is launched as a service.

Issue:
When nextcloud-client is launched through the service, it’s unable to open web browsers (I’ve tried with Zen browser and Firefox) via XDG. However, when launched from the command line, it works without issues.

My current service configuration:

nextcloud-client = {
  Service = {
    ExecStart = "${pkgs.nextcloud-client}/bin/nextcloud";
    Environment = [ ];
  };
};

Additional testing:
I’ve also tried a dummy service to test xdg-open directly, and it exhibits the same behavior:

open-zen = {
  Service = {
    ExecStart = "${pkgs.xdg-utils}/bin/xdg-open https://duck.ai";
    Environment = [ ];
  };
};

Environment:

  • I’m using Wayland as my display server.
  • The issue only occurs when running as a service, not from CLI.

Questions:

  1. Do I need to add specific environment variables to my service configuration?
  2. Are there any Wayland-specific considerations for XDG functionality in services?
  3. How can I ensure that nextcloud-client (and other XDG-dependent services) can properly interact with the desktop environment when run as a service?

Any insights or solutions would be greatly appreciated. Thanks in advance for your help!

Have you tried to set xdg.portal.xdgOpenUsePortal = true, rebuild and then reboot? That fixed the issue for me.

I’d also recommend to not use a Systemd service for a graphical program in general - use your desktop environment’s autostart support - by placing a .desktop file in ~/.config/autostart. Usually that’s what Graphical applications do under the hood when you open their settings and set a “launch on startup” button or alike.

1 Like

If you need more help beyond that, please specify which compositor you’re using, just “wayland” is a bit too vague. (Not every compositor even supports xdg autostart for example.)