{{tag>tumbleweed systemd howto nextclouddesktopclient suse nextcloud kde session}} ====== Nextcloud Desktop as a user service with systemd ====== * https://blog.victormendonca.com/2018/05/14/creating-a-simple-systemd-user-service/ * https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_and_managing_networking/systemd-network-targets-and-services_configuring-and-managing-networking * https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/ * https://www.freedesktop.org/software/systemd/man/systemd-networkd-wait-online.service.html * https://www.freedesktop.org/software/systemd/man/systemd.special.html * https://forum.qt.io/topic/93247/qt-qpa-plugin-could-not-load-the-qt-platform-plugin-xcb-in-even-though-it-was-found/9 * https://github.com/nextcloud/desktop/issues/728 * https://www.unixsysadmin.com/systemd-user-services/ * https://www.linuxquestions.org/questions/linux-desktop-74/start-gui-application-from-systemd-unit-service-4175591018/ * https://www.makeuseof.com/what-is-systemd-launch-programs-raspberry-pi/ * https://blog.svedr.in/posts/running-the-nextcloud-client-under-systemd/ Since quite some time I am annoyed by the Nextcloud client starting before the internet connection becomes available. That leads to a situation in which the Nextcloud Desktop Client presents a browser window with a login mask because it assumes it is disconnected. My approach will start and manage the Nextcloud Desktop Client as a systemd user service as soon as a network connection becomes ready. This is working on openSUSE Tumbleweed with KDE as of 2021/10/13. On other operating systems your mileage may vary. ===== KDE Session Management, Autostart ===== * remove Nextcloud from autostart * tick "start with an empty session" under "Desktop Session" in System Settings ===== Wait System Service ===== Check if the correct oneshot "wait" system service is enabled (NetworkManager in my case). systemctl is-enabled NetworkManager-wait-online.service systemd-networkd-wait-online.service enabled Failed to get unit file state for systemd-networkd-wait-online.service: No such file or directory ===== Systemd User Service ===== # as user mkdir -pv ~/.config/systemd/user/ vim ~/.config/systemd/user/nextcloud-desktop.service [Unit] Description=Nextcloud Desktop Client After=network-online.target Wants=network-online.target NetworkManager-wait-online.service [Service] Type=simple StandardOutput=journal ExecStart=/usr/bin/nextcloud Restart=on-failure RestartSec=5s LimitNOFILE=65535:65535 [Install] WantedBy=default.target enable the service systemctl --user enable nextcloud-desktop.service start the service systemctl --user start nextcloud-desktop.service check that the service is running systemctl --user status nextcloud-desktop.service ---- ~~DISCUSSION~~