feat: flatpaksync module
This commit is contained in:
parent
dbb67ea43d
commit
1cbaa10135
6 changed files with 97 additions and 0 deletions
27
files/usr/bin/flatpaksync/flatpakcheckout
Executable file
27
files/usr/bin/flatpaksync/flatpakcheckout
Executable 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
|
||||
13
files/usr/bin/flatpaksync/flatpaksync
Executable file
13
files/usr/bin/flatpaksync/flatpaksync
Executable 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
|
||||
10
files/usr/lib/systemd/user/flatpaksync.path
Normal file
10
files/usr/lib/systemd/user/flatpaksync.path
Normal 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
|
||||
12
files/usr/lib/systemd/user/flatpaksync.service
Normal file
12
files/usr/lib/systemd/user/flatpaksync.service
Normal 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
|
||||
22
modules/flatpak-sync/README.md
Normal file
22
modules/flatpak-sync/README.md
Normal 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.
|
||||
13
modules/flatpak-sync/flatpak-sync.sh
Normal file
13
modules/flatpak-sync/flatpak-sync.sh
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue