feat: work on distributions other than Arch
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.
This commit is contained in:
1 parent
bd84c6645a
commit
36498f2acf
13 files changed
+455
-81
No files matched your search
@@ -18,7 +18,9 @@ on the command line.
|
||||
|
||||
*middleclick-autoscroll* finds every Chromium-based application on the system
|
||||
and puts that argument somewhere the application will actually read it, then
|
||||
keeps doing so for anything installed later.
|
||||
keeps doing so for anything installed later. It works on any distribution:
|
||||
which of the routes below an application takes is read off its launcher, not
|
||||
assumed from where the launcher came from.
|
||||
|
||||
Run without a command it shows an interactive menu. Everything it can be told
|
||||
is reachable from there; the configuration file behind it does not need to be
|
||||
@@ -66,7 +68,7 @@ is refused.
|
||||
Two ways, chosen per application.
|
||||
|
||||
*Flag file*
|
||||
Arch's Electron and Chromium wrappers read extra arguments from
|
||||
Where the launcher reads extra arguments from
|
||||
_$XDG_CONFIG_HOME/<name>-flags.conf_. This is the preferred route: it is
|
||||
the supported way to pass arguments, it survives package upgrades, and it
|
||||
applies to a launch from a terminal as much as one from the menu. An
|
||||
@@ -74,12 +76,22 @@ Two ways, chosen per application.
|
||||
rather than duplicated - Chromium keeps only the last occurrence of that
|
||||
option, so a second one would switch the first one off.
|
||||
|
||||
Arch's Electron and Chromium packages all wrap their binaries this way, and
|
||||
so do a number of individual vendors' launchers elsewhere. Whether a given
|
||||
launcher does is read off the launcher itself, never assumed from the
|
||||
distribution: only one that really names such a file takes this route.
|
||||
|
||||
*Desktop entry*
|
||||
For applications that ship their own binary with no wrapper, and for
|
||||
Flatpaks, a copy of the desktop entry with the argument appended is written
|
||||
to _~/.local/share/applications_, where it shadows the system one. Entries
|
||||
that already live there - AppImages, web app shortcuts - are edited in
|
||||
place, with the original kept.
|
||||
everything inside a Flatpak or a snap, a copy of the desktop entry with the
|
||||
argument appended is written to _~/.local/share/applications_, where it
|
||||
shadows the system one. Entries that already live there - AppImages, web
|
||||
app shortcuts - are edited in place, with the original kept.
|
||||
|
||||
This is the route everything takes on the distributions whose Chromium
|
||||
wrappers keep their equivalent file under _/etc_, where it is the system's
|
||||
to write and not the user's: Debian, Ubuntu, Fedora and openSUSE among
|
||||
them.
|
||||
|
||||
A generated entry is marked *X-MCA-Generated* and an entry edited in place
|
||||
*X-MCA-Patched*. The two are never confused: the first is deleted when
|
||||
@@ -98,6 +110,11 @@ helper, inside Steam's own installation:
|
||||
|
||||
~/.local/share/Steam/ubuntu12_64/steamwebhelper_sniper_wrap.sh
|
||||
|
||||
Where that installation is depends on how Steam was installed:
|
||||
_~/.local/share/Steam_ for Valve's own package and Arch's,
|
||||
_~/.steam/debian-installation_ for Debian's, and the private tree of the
|
||||
sandbox for the Flatpak and the snap. All of them are looked at.
|
||||
|
||||
Steam compares the installed files against its manifest at every start - by
|
||||
size, not by content - and restores whatever differs, so its launcher entry
|
||||
gets *-noverifyfiles*. So does its entry in _~/.config/autostart_, which Steam
|
||||
@@ -125,8 +142,8 @@ anyway.
|
||||
The official client is CEF rather than Electron. Installed through
|
||||
*spotify-launcher*, it is started by a program that builds its own command line
|
||||
and has a configuration file with a slot for extra arguments; that slot is
|
||||
where the flag goes. Installed as a plain package, it is an ordinary desktop
|
||||
entry and needs nothing special.
|
||||
where the flag goes. Installed as a plain package, a Flatpak or a snap, it is
|
||||
an ordinary desktop entry and needs nothing special.
|
||||
|
||||
# WHAT CANNOT BE DETECTED
|
||||
|
||||
@@ -155,9 +172,15 @@ _~/.cache/middleclick-autoscroll/detect_
|
||||
*NO_COLOR*
|
||||
Disables colour.
|
||||
|
||||
# REQUIREMENTS
|
||||
|
||||
Bash 4.2 or newer and GNU coreutils. The watcher needs a systemd user session;
|
||||
without one everything else works and applications installed later are picked
|
||||
up at the next *apply* rather than on their own.
|
||||
|
||||
# SEE ALSO
|
||||
|
||||
*systemctl*(1), *flatpak*(1)
|
||||
*systemctl*(1), *flatpak*(1), *snap*(8)
|
||||
|
||||
# AUTHORS
|
||||
|
||||
|
||||
Reference in new issue
Block a user