deltachat / deltachat-desktop

Email-based instant messaging for Desktop.
GNU General Public License v3.0
909 stars 167 forks source link

Option to setup autostart for Deltachat #2518

Open Simon-Laux opened 2 years ago

Simon-Laux commented 2 years ago

Option to set up auto start for Deltachat on system start. If we cannot support a certain system/os we can link to a tutorial/guide how the user can do it manually.

This should become an option in the Settings. (activate autostart and disable autostart), in all cases it should be started with the --minimized cli argument.

lets collect the approaches how we could do it on the different OS/platforms/distribution-formats:

Windows (normally installed)

For windows (non store/non-appx) we could create a link/shortcut file in the StartMenu/Autostart folder, that is set to start Deltachat with the minimised argument. There is probably also a way to do this via the windows registry.

Windows (portable)

Either don't offer option at all (and display a manual guide), or do the same method as for the installed version but put a warning before it "Does not work with portable versions on a path that changes"

At beginning check how it was installed (user, globally or portable) (check executable path). If path is not known then warn user as written above.

For current user:

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]
"DeltaChat"="%USERPROFILE%\AppData\Local\Programs\DeltaChat\DeltaChat.exe"

For all users (only this additional option show option if dc was installed for all users, probably requires some prompt to add it with admin rights?):

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"DeltaChat"="path to global dc"

Windows (apps, Store version)

there is an npm package for this: https://github.com/felixrieseberg/electron-winstore-auto-launch

MacOS

?, probably not the biggest deal to not have it, because macOS normally restarts all previous applications after a reboot.

Linux (normally installed & AppImage)

copy deltachat.desktop file to ~/.config/autostart for a particular user (as per XDG Autostart).

Linux (flatpak)

use bus to communicate with flatpack:

def generateFlatpak(typeAction):
    try:
        bus = dbus.SessionBus()
        obj = bus.get_object("org.freedesktop.portal.Desktop",
                             "/org/freedesktop/portal/desktop")
        inter = dbus.Interface(obj, "org.freedesktop.portal.Background")

        res = inter.RequestBackground('', {'reason': 'Zapzap autostart', 'autostart': typeAction,
                                           'background': typeAction, 'commandline': dbus.Array(['zapzap', '--hideStart'])})

    except Exception as e:
        print(e)

https://github.com/rafatosta/zapzap/blob/f645c2a3f26cc80af45d11299432e9d1ced81bd8/zapzap/services/portal_desktop.py#L18-L29

PS: we might need to modify electron builder for this so that it allows us to write what distributable format it is before packing the app into that format.

gerryfrancis commented 2 years ago

There is probably also a way to do this via the windows registry.

For current user:

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]
"DeltaChat"="%USERPROFILE%\AppData\Local\Programs\DeltaChat\DeltaChat.exe"

For all users:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"DeltaChat"="C:\Program Files (x86)\DeltaChat\DeltaChat.exe"

Although I am not absolutely sure about the program path for the all-user installation...

jose1711 commented 2 years ago

Linux (normally installed)

?

copy deltachat.desktop file to ~/.config/autostart for a particular user (as per XDG Autostart).

link2xt commented 11 months ago

There is a related forum topic on https://support.delta.chat/t/start-minimized-as-an-option/2057

debilin commented 10 months ago

We can take a look at ZapZap build for Flatpak. I think they did a good job for Flatpak to autostart.