4

Many GNU/Linux distros come with autostarts configured that are not needed for most users and are a privacy and security risk (even if small). In principle, it makes sense to only autostart things one actually needs to reduce the likelihood of crashes, the number of irrelevant log entries, the hardware resource consumption, and the attack surface (for example due to potential vulnerabilities in any of the software or ports they listen on).

A problem is that when upgrading packages or the distro like Debian, the autostart could be enabled again. What is the best way to permanently disable autostarting without removing the package (which often isn't even possible anyway as the autostarting package comes shipped with some other needed package).

At various questions each about one particular undesired by-default-autostarting software different methods to disable the autostart have been recommended:

  • Removing (or moving) the file in the autostart folder like so for the Orca screenreader sudo rm /etc/xdg/autostart/orca-autostart.desktop
  • Something like systemctl --user disable at-spi-dbus-bus.service as recommended here for the screenreader KDE Accessible or for the geolocation tracker geoclue-demo-agent.desktop
  • Removing the executable flag so it needs to first be manually set (with +x) whenever one wants to run the app like sudo chmod -x /usr/bin/kdeconnectd && pkill kdeconnectd or for Debian12 sudo chmod -x /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd && pkill kdeconnectd as recommended here for the wireless communication listener KDE Connect
  • Copying the .desktop file to the .config folder and changing things so that it doesn't autostart (ironically that makes it show up in KDE's System Settings->Autostart while it wasn't shown there before) for example like so cp /etc/xdg/autostart/org.kde.kalendarac.desktop ~/.config/autostart and then changing crc:General:Autostart:true to false :false in the file in ~/.config as recommended here for Calendar Reminders or adding Hidden=true to that file as recommended here
  • Renaming the file in /etc/xdg/autostart/to filename.desktop.disabled
  • Removing it from the D-Bus autostart services /usr/share/dbus-1/services/ or putting a modified version into ~/.local/share/dbus-1/services/
  • A combination of the above such as removing the file from the autostart folder but leaving a .config file that should disable the autostart if it gets restored by some upgrade (especially a distro upgrade).

Now I don't know which way to use and all the ones I tried seem to get reset after an upgrade. The .desktop file can get overwritten if the package gets upgraded.

1
  • 1
    Yet another possibility - worked for me locally, but this was not on a Debian system so YMMV: systemctl --user mask [email protected] seems to work for me to disable the service generated from /etc/xdg/autostart/pulseaudio.desktop. (Haven't tried this one, but I'd guess sudo systemctl --global mask [email protected] could work to make it apply across all users.) Commented Apr 11, 2024 at 18:59

1 Answer 1

5

If an autostart file exists in /etc/xdg/autostart, then copying it to ~/.config/autostart and adding Hidden=True will work even after the package is updated. If the option exists to disable/mask the service, then that approach should also survive an update.

One additional method you did not mention, but may also be a solution: if the program respects a drop-in directory - sudo, for example reads files in /etc/sudoers.d - then custom settings here might also work.

3
  • You don't need a file in /etc/xdg/autostart for this to work (and no need to copy anything). Just create a file named e.g. firefox.desktop in ~/.config/autostart w/ two lines, [Desktop Entry] and Hidden=true to disable its autostart (or set Hidden=true in the file if it exists there already) Commented Apr 30, 2024 at 21:14
  • Well, the first part of my answer deals specifically with programs that auto-start from /etc/xdg/autostart. Not sure how your suggestion would block an app from starting this way if there's no entry there. Commented May 1, 2024 at 3:46
  • Apparently ~/.config/autostart masks not only /etc/xdg/autostart (tested on Debian bullseye) Commented May 1, 2024 at 19:51

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.