Commit Graph

22 Commits

Author SHA1 Message Date
Martin Kühl
16707a1937 profile.d: Only add new directories to XDG_DATA_DIRS in fish
Previously in a0505f52d9
the profile script was modified to preserve XDG_DATA_DIRS.
This had the side-effect of making the script not idempotent,
adding duplicate entries for every installation every time it's sourced.

On my current system  that results in this value:

    /home/mkhl/.local/share/flatpak/exports/share /var/lib/flatpak/exports/share /home/mkhl/.local/share/flatpak/exports/share /var/lib/flatpak/exports/share /usr/local/share /usr/share

which in turn has the side-effect of the GNOME search settings showing two entries
for every application installed via flatpak.

This change makes the script check that an entry is new before adding it.
It also uses `set -p` (short for `--prepend`) to add them.

N.B.
`set -p VAR val` is equivalent to `set VAR val $VAR`
`$var[-1..1]` reverses the order of elements
so after iterating the first element of `$installations`
becomes the first element of `$XDG_DATA_DIRS`
2022-12-04 11:43:30 -06:00
Simon McVittie
9eb824f863 Add a Meson build system
Resolves: https://github.com/flatpak/flatpak/issues/2241
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-24 16:12:14 +01:00
Jan Tojnar
a0505f52d9 profile.d: Do not destroy XDG_DATA_DIRS in fish
The profile script previously nuked `XDG_DATA_DIRS` and then
“helpfully” re-populated it with FHS paths. This was especially
bad for systems like NixOS, which do not have `/usr`
and rely on `XDG_DATA_DIRS` heavily.

Quoting from https://fishshell.com/docs/current/cmds/set.html

> If a variable is set to zero elements, it will become a list with zero elements.

And indeed, that is what the `set -x --path XDG_DATA_DIRS` command does.
We need to list the value explicitly, if we want to preserve it
while setting variable options.
2022-10-14 12:24:21 +01:00
Ryan Gonzalez
d37c739f6c Add a profile script for Fish
Technically, Fish users can already make this work using
https://github.com/edc/bass, but it's also nice to have this working on
an out-of-the-box Flatpak installation.

Fixes #3109.

Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
2021-11-15 10:44:55 +01:00
Simon McVittie
afe7f2bf78 env.d, profile.d: Disable gvfs plugins during login
This avoids gvfs-daemon being started when logging in as root via ssh.

Bug-Debian: https://bugs.debian.org/975710
2021-01-11 11:07:26 +01:00
Mourad De Clerck
f69a35ceec profile.d: Disable gvfs plugins when listing flatpak installations
This avoids gvfs-daemon being started when logging in as root via ssh.

Bug-Debian: https://bugs.debian.org/975710
2021-01-11 11:07:26 +01:00
Werner Fink
e0c0c43728 Add also support for tcsh users
Signed-off-by: Werner Fink <werner@suse.de>
2020-08-10 15:20:36 +02:00
Ross Timson
a48f46f314 profile: Fix for openbsd ksh.
When using OpenBSD ksh `flatpak.sh` gives the following error:

	/etc/profile.d/flatpak.sh[16]: syntax error: `;;' unexpected

By adding in the POSIX compliant optional opening parentheses for the
case statement branches the profile can be made more portable.  This
still works with them more common shells such as bash and zsh and also
still passes `shellcheck` checks.

Aware that using OpenBSD ksh on Linux might be an edge case but there
are probably BSD users who need to use Linux for work such as myself but
still want to use the OBSD shell which has been ported to Linux:
https://github.com/dimkr/loksh

Many thanks to @gumnos for pointing out the fix here via Twitter.

Closes: #2947
Approved by: mwleeds
2019-06-11 19:20:25 +00:00
Simon McVittie
684b19e719 profile: Only alter XDG_DATA_DIRS if flatpak is still installed
In some OSs, removing a package does not immediately remove its
configuration files in /etc. In particular, `dpkg --remove` or
`apt-get remove` in Debian derivatives leaves configuration files intact
so that the package can be reinstalled later without having to
reconfigure it, with `dpkg --purge` or `apt-get purge` used to remove
the configuration files too.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Closes: #2840

Closes: #2849
Approved by: alexlarsson
2019-04-25 08:12:35 +00:00
Debarshi Ray
7c8f21e0a4 profile: Unbreak XDG_DATA_DIRS when debug logging is enabled
If G_MESSAGES_DEBUG is set in the shell's start-up scripts, then the
"flatpak --installations" output is contaminated with these strings:
  (flatpak:4558): flatpak-DEBUG: ...

Fallout from 30c2919624

Closes: #2673
Approved by: alexlarsson
2019-02-01 16:30:52 +00:00
Simon McVittie
2a25ecf6ee profile: Don't rely on bash syntax
In Debian, we reuse flatpak.sh in /etc/X11/Xsession.d (which is sourced
by /bin/sh, normally dash) so that these environment variables become
part of the X11 session environment. We might also have
non-bash-compatible shells that read profile.d (I'm not sure).

Fixes #2594

Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #2597
Approved by: matthiasclasen
2019-01-16 00:08:21 +00:00
Matthias Clasen
6cac94e706 Simplify profile.d handling
There is no need to generate this script when the
only variable part in it is a comment. Reword the
comment.

Closes: #2122
Approved by: matthiasclasen
2019-01-08 00:26:17 +00:00
Matthias Clasen
30c2919624 profile: Use flatpak --installations
This ensures that we end up with the same installations
in XDG_DATA_DIRS, regardless which way this variable
gets set.

Closes: #2122
Approved by: matthiasclasen
2019-01-08 00:26:17 +00:00
Simon McVittie
e572311a26 Improve and simplify profile snippet
Avoid setting a temporary variable flatpak_dirs which, while not
exported to the environment, would still be defined as a
shell "parameter" (variable) in the login shell itself.

Consistently put the Flatpak directories before other XDG_DATA_DIRS,
rather than putting them last if XDG_DATA_DIRS happens to be already
set.

Expand XDG_DATA_HOME if necessary, rather than assuming it will
always be ~/.local/share.

I don't know exactly which shells source profile.d, but it's possible
that one of them might only implement POSIX test syntax, so prefer
[ x = y ] over [ x == y ].

Fix some insufficient quoting that could have gone wrong if
XDG_DATA_DIRS somehow contained spaces.

Signed-off-by: Simon McVittie <smcv@debian.org>
2017-03-14 21:48:58 +01:00
Alexander Larsson
93347f4a6d profile: Don't add flatpak to XDG_DATA_DIRS if its already there
(cherry picked from commit f09d6b3aa6)
2017-03-10 11:29:29 +01:00
Elvis Angelaccio
a9acdc0532 Append flatpak data dirs if XDG_DATA_DIRS is already set (#611)
* Append flatpak data dirs if XDG_DATA_DIRS is already set

Otherwise it will be impossible to run flatpak apps from desktop menus.
This issue can happen if another app (e.g. snapd) wants to add custom
folders to XDG_DATA_DIRS through /etc/profile.d

If XDG_DATA_DIRS is empty or unset, define it as before.

Fixes #606
2017-03-08 08:38:47 +01:00
Alexander Larsson
e9c67ec47f Get the system installation dir right in XDG_DATA_DIRS
Its in /var/lib/flatpak, not /var/flatpak
2016-05-20 09:21:19 +02:00
Alexander Larsson
5e9b247d26 Migrate ~/.local/share/xdg-app to ~/.local/share/flatpak 2016-05-09 12:21:28 +02:00
Alexander Larsson
8abbc0186e Rename everything but the on-disk location to flatpak 2016-05-09 11:11:55 +02:00
Alexander Larsson
c7a05ae781 profile: Don't override pre-existing XDG_DATA_DIRS env vars 2015-06-24 09:31:50 +02:00
Alexander Larsson
c5a2bb2b07 xdg-app.sh: /usr/local/share is also in the default XDG_DATA_DIRS 2015-06-23 11:38:55 +02:00
David King
27fdae4153 Add a simple profile.d snippet for XDG_DATA_DIRS
https://github.com/alexlarsson/xdg-app/issues/74
2015-05-15 17:00:38 +01:00