feat: flatpaksync module

This commit is contained in:
Lucas Ribeiro 2023-10-12 08:48:35 -03:00
parent dbb67ea43d
commit 1cbaa10135
No known key found for this signature in database
GPG key ID: 5EF9C1683DC0E253
6 changed files with 97 additions and 0 deletions

View file

@ -0,0 +1,27 @@
#!/usr/bin/env bash
CHECKOUT_DIR=/tmp/sync
rm -rf $CHECKOUT_DIR
if [[ -n "${GIST_REPO}" ]]; then
git clone "$GIST_REPO" $CHECKOUT_DIR || exit 0
while IFS=$'\n' read -r app; do
flatpak install --user --noninteractive "$app" -y || HAS_FAILED="yes"
done <$CHECKOUT_DIR/flatpak.list
if [[ -z "${HAS_FAILED}" ]]; then
touch "$HOME"/.config/flatpaks.user.installed
fi
else
echo "Repository not specified. Please enter it in $HOME/.config/flatpaksync/env in the POSIX pattern: GIST_REPO=<YOUR_REPO>"
fi

View file

@ -0,0 +1,13 @@
#!/usr/bin/env bash
CHECKOUT_DIR=/tmp/sync
git clone "$GIST_REPO" $CHECKOUT_DIR || exit 0
flatpak list --app --columns=app --user > $CHECKOUT_DIR/flatpak.list
cd $CHECKOUT_DIR || exit 0
git add . && git commit -m "." && git push
rm -rf $CHECKOUT_DIR

View file

@ -0,0 +1,10 @@
[Unit]
Description=Monitorar o diretório ~/.var/app
[Path]
PathChanged=%h/.var/app
PathChanged=%h/.config/flatpaks.user.installed
Unit=flatpaksync.service
[Install]
WantedBy=default.target

View file

@ -0,0 +1,12 @@
[Unit]
Description=Serviço de sincronia de flatpak
ConditionPathExists=%h/.config/flatpaksync/env
ConditionPathExists=%h/.config/flatpaks.user.installed
[Service]
EnvironmentFile=%h/.config/flatpaksync/env
ExecStart=/usr/bin/flatpaksync
Type=simple
[Install]
WantedBy=default.target

View file

@ -0,0 +1,22 @@
# `flatpaksync` Module for Startingpoint
The `flatpaksync` module can be used to synchronize user-installed flatpaks into a gist.
To activate it, simply follow the example below:
## Example configuration
```yaml
- type: flatpaksync
enable: true
```
Once the module is activated, users can create a file `$HOME/.config/flatpaksync/env` informing the repository that will be used to synchronize their apps in the POSIX standard:
```bash
GIST_REPO=<YOUR_REPO>
```
If the user has not yet installed their flatpaks and has already done the step above, simply use the `flatpakcheckout` binary to perform the installation and start the synchronization.
If the user has already configured their repository in the `$HOME/.config/flatpaksync/env` file but already has their flatpaks installed, simply create the `$HOME/.config/flatpaks.user.installed` file to start the synchronization.

View file

@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -oue pipefail
export BLING_FILES_DIRECTORY="/tmp/bling/files"
chmod +x "$BLING_FILES_DIRECTORY"/usr/bin/flatpaksync/*
cp -r "$BLING_FILES_DIRECTORY"/usr/bin/flatpaksync/* /usr/bin/
cp -r "$BLING_FILES_DIRECTORY"/usr/lib/systemd/user/flatpaksync.service /usr/lib/systemd/user/flatpaksync.service
cp -r "$BLING_FILES_DIRECTORY"/usr/lib/systemd/user/flatpaksync.path /usr/lib/systemd/user/flatpaksync.path
systemctl enable --global flatpaksync.path