The README asked for "Arch or an Arch derivative" and the code had two
reasons for it. Neither of them was the mechanism, which is why this is
mostly a matter of not assuming.
The first was the flag file. Arch wraps Electron and Chromium in launchers
that read $XDG_CONFIG_HOME/<name>-flags.conf, and that route is the good
one - it survives upgrades and applies to a launch from a terminal. Debian,
Ubuntu, Fedora and openSUSE keep the equivalent under /etc, where it is the
system's file and not the user's, so there is nothing to write and those
applications have to go through their desktop entry instead. That already
worked, because a launcher is read rather than assumed - but only if the
launcher was recognised as Chromium at all, and it was not:
APPNAME=chromium
LIBDIR=/usr/lib/chromium
exec -a "$APPNAME" "$LIBDIR/$APPNAME" $CHROMIUM_FLAGS "$@"
is the shape every one of those wrappers has, and following it needs the
assignments above resolved and -a understood as renaming the process rather
than naming the program. Both are done now, and the wrappers that still
cannot be followed are caught by CHROMIUM_FLAGS and CHROME_WRAPPER, which
nothing but a Chromium launcher sets. Two applications on the machine this
was written on turn out to have been missed for the same reason: Helium,
whose wrapper is followed to a payload full of markers, and ONLYOFFICE,
which ships libcef.so.
Resolving more wrappers made an old inference dangerous. Any launcher that
could be followed also had "<target>-flags.conf" invented for it, on the
theory that a wrapper builds that name from a variable at runtime. For an
application that simply execs its own binary that file is read by nobody:
the flag would have gone to ~/.config/DesktopEditors-flags.conf and the
desktop entry that would have worked was skipped. The name is now derived
only once the target has shown it reads a flag file at all.
The second reason was snaps. /snap/bin/<name> is a symlink to snapd, so
following it lands on /usr/bin/snap and says nothing; the payload is in the
mounted revision, and that tree takes the same marker check as anything
else. They get a settings switch of their own next to Flatpak, and the
launcher entry as their only way in.
Packaging is now a gate in front of the category rather than a category
beside it. A Chromium installed as a snap or a Flatpak was filed as neither
an application nor a browser, so turning browsers off did not reach it -
which on Ubuntu means the default browser. It is a browser that happens to
be packaged as a snap, and both switches apply.
The rest is the same not-assuming: Steam is found in Debian's
~/.steam/debian-installation and in the snap's private tree, the Flatpak
and snap export directories are scanned even when a session started before
they were installed left them out of XDG_DATA_DIRS, /usr/lib/x86_64-linux-gnu
counts as a shared directory the way /usr/lib does, the watcher covers
snapd's export directory and the NixOS and Guix profiles, LANG is read from
/etc/default/locale as well as /etc/locale.conf, and the systemd user unit
directory is asked of systemd instead of guessed - while still following a
PREFIX that was asked for.
38 lines
1.7 KiB
SYSTEMD
38 lines
1.7 KiB
SYSTEMD
[Unit]
|
|
Description=Watch for newly installed Chromium-based applications
|
|
Documentation=man:middleclick-autoscroll(1)
|
|
|
|
[Path]
|
|
# Every way an application can turn up: a package, a Flatpak, a snap, something
|
|
# installed by hand. Watching where the launchers land means there is no hook
|
|
# to write per package manager - pacman, apt, dnf, zypper, flatpak, snapd and
|
|
# an AppImage manager all end up here.
|
|
#
|
|
# A directory that does not exist on this system costs nothing: systemd watches
|
|
# the nearest parent that does and picks the path up when it appears.
|
|
PathModified=/usr/share/applications
|
|
PathModified=/usr/local/share/applications
|
|
PathModified=%h/.local/share/applications
|
|
PathModified=%h/.config/autostart
|
|
PathModified=/var/lib/flatpak/exports/share/applications
|
|
PathModified=%h/.local/share/flatpak/exports/share/applications
|
|
PathModified=/var/lib/snapd/desktop/applications
|
|
|
|
# NixOS and Guix build the search path out of profiles rather than /usr.
|
|
PathModified=/run/current-system/sw/share/applications
|
|
PathModified=%h/.nix-profile/share/applications
|
|
PathModified=%h/.guix-profile/share/applications
|
|
|
|
# Steam replaces the script that starts its interface on every client update,
|
|
# which takes the patch with it. Where that installation lives depends on how
|
|
# Steam was installed.
|
|
PathChanged=%h/.local/share/Steam/ubuntu12_64/steamwebhelper_sniper_wrap.sh
|
|
PathChanged=%h/.steam/debian-installation/ubuntu12_64/steamwebhelper_sniper_wrap.sh
|
|
PathChanged=%h/.var/app/com.valvesoftware.Steam/.local/share/Steam/ubuntu12_64/steamwebhelper_sniper_wrap.sh
|
|
PathChanged=%h/snap/steam/common/.local/share/Steam/ubuntu12_64/steamwebhelper_sniper_wrap.sh
|
|
|
|
Unit=middleclick-autoscroll.service
|
|
|
|
[Install]
|
|
WantedBy=default.target
|