fix(default-flatpaks): Install/uninstall system flatpaks regardless i… (#100)

* fix(default-flatpaks): Install/uninstall system flatpaks regardless if current user has permissions or not

Fixes: https://github.com/ublue-os/bling/pull/93

To make notify-send working for --system systemd units, I have to thank @gerblesh for his code & idea in ublue-updater.

I tested this in Silverblue & it works.
However, I would like this to be tested in other DEs like Kinoite too, to see if it's working correctly.

Feel free to improve code if you find some space for that.

@lorduskordus

* Use json parser instead as a more reliable solution on fetching values

* There is no need for echo when parsing json

* Fetch DISPLAY environment variable from printenv

* Make functions for notify-sends, to make script clearer

* Whiteline fixes
This commit is contained in:
fiftydinar 2024-01-20 17:38:51 +01:00 committed by GitHub
parent 17bacbe3da
commit fe9cd68c6a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 60 additions and 67 deletions

View file

@ -6,17 +6,15 @@ Flatpaks can either be installed system-wide or per-user, though per-user flatpa
The module uses the following scripts to handle flatpak setup:
- `/usr/bin/system-flatpak-presetup`
- `/usr/bin/system-flatpak-setup`
- `/usr/bin/user-flatpak-setup`
The scripts are run on every boot by these services:
- `/usr/lib/systemd/system/system-flatpak-presetup.service`
- `/usr/lib/systemd/system/system-flatpak-setup.service`
- `/usr/lib/systemd/user/user-flatpak-setup-service`
`system-flatpak-presetup` uninstalls Fedora flatpaks & replaces Fedora repos with your system repos (needs root, hence why it's presetup). `system-flatpak-setup` checks the flatpak install/remove lists created by the module & performs the install/uninstall operation according to that. `user-flatpak-setup` functions the same for user flatpaks, with additional "user" replacement repo operation.
`system-flatpak-setup` uninstalls Fedora flatpaks, replaces Fedora repos with your repo choice, checks the flatpak install/remove lists created by the module & performs the install/uninstall operation according to that. `user-flatpak-setup` functions the same for user flatpaks.
This module stores the Flatpak remote configuration and Flatpak install/remove lists in `/etc/flatpak/`. There are two subdirectories, `user` and `system` corresponding with the install level of the Flatpaks and repositories. Each directory has text files containing the IDs of flatpaks to `install` and `remove`, plus a `repo-info.yml` containing the details of the Flatpak repository.

View file

@ -5,11 +5,9 @@ set -euo pipefail
BLING_DIRECTORY="${BLING_DIRECTORY:-"/tmp/bling"}"
cp -r "$BLING_DIRECTORY"/files/usr/bin/system-flatpak-presetup /usr/bin/system-flatpak-presetup
cp -r "$BLING_DIRECTORY"/files/usr/bin/system-flatpak-setup /usr/bin/system-flatpak-setup
cp -r "$BLING_DIRECTORY"/files/usr/bin/user-flatpak-setup /usr/bin/user-flatpak-setup
cp -r "$BLING_DIRECTORY"/files/usr/lib/systemd/system/system-flatpak-presetup.service /usr/lib/systemd/system/system-flatpak-presetup.service
cp -r "$BLING_DIRECTORY"/files/usr/lib/systemd/user/system-flatpak-setup.service /usr/lib/systemd/user/system-flatpak-setup.service
cp -r "$BLING_DIRECTORY"/files/usr/lib/systemd/system/system-flatpak-setup.service /usr/lib/systemd/system/system-flatpak-setup.service
cp -r "$BLING_DIRECTORY"/files/usr/lib/systemd/user/user-flatpak-setup.service /usr/lib/systemd/user/user-flatpak-setup.service
configure_flatpak_repo () {
@ -106,8 +104,7 @@ configure_lists () {
echo "Enabling flatpaks module"
mkdir -p /usr/etc/flatpak/{system,user}
systemctl enable -f system-flatpak-presetup.service
systemctl enable -f --global system-flatpak-setup.service
systemctl enable -f system-flatpak-setup.service
systemctl enable -f --global user-flatpak-setup.service
# Check that `system` is present before configuring