feat: flatpaksync submodule (#62)
This commit is contained in:
commit
a21e245279
6 changed files with 96 additions and 0 deletions
29
files/usr/bin/flatpaksync/flatpakcheckout
Executable file
29
files/usr/bin/flatpaksync/flatpakcheckout
Executable file
|
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
source $HOME/.config/flatpaksync/env
|
||||
|
||||
CHECKOUT_DIR=/tmp/sync
|
||||
|
||||
rm -rf $CHECKOUT_DIR
|
||||
|
||||
if [[ -n "${GIT_REPO}" ]]; then
|
||||
|
||||
git clone "$GIT_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: GIT_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
|
||||
|
||||
rm -rf $CHECKOUT_DIR
|
||||
|
||||
git clone "$GIT_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
|
||||
10
files/usr/lib/systemd/user/flatpaksync/flatpaksync.path
Normal file
10
files/usr/lib/systemd/user/flatpaksync/flatpaksync.path
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
[Unit]
|
||||
Description=Service monitoring the ~/.var/app directory
|
||||
|
||||
[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/flatpaksync.service
Normal file
12
files/usr/lib/systemd/user/flatpaksync/flatpaksync.service
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
[Unit]
|
||||
Description=Flatpak synchronization service
|
||||
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
|
||||
|
|
@ -19,4 +19,23 @@ install:
|
|||
# - gnome-vrr # enables gnome-vrr for your image
|
||||
# - container-tools # installs container-related tools onto /usr/bin: kind, kubectx, docker-compose and kubens
|
||||
# - laptop # installs TLP and configures your system for laptop usage
|
||||
# - flatpaksync # allows synchronization of user-installed flatpaks, see separate documentation section
|
||||
```
|
||||
## Submodule documentation
|
||||
|
||||
### `flatpaksync`
|
||||
|
||||
The `flatpaksync` submodule can be used to synchronize a list of user Flatpaks with a git repository.
|
||||
|
||||
Once the submodule is activated, you should create the file `$HOME/.config/flatpaksync/env` that sets the `GIT_REPO` variable to the git URL of your repository. This repository can be empty, or a previous flatpaksync installation. The repository is automatically cloned into `/tmp/sync` for the synchronization.
|
||||
|
||||
```bash
|
||||
# ~/.config/flatpaksync/env
|
||||
GIT_REPO=<YOUR_REPO>
|
||||
```
|
||||
|
||||
To initialize your Flatpaks from flatpaksync, simply run the `flatpakcheckout` binary to perform the installation and start the synchronization.
|
||||
|
||||
**It is important to note that this submodule will NOT enable Flathub. If your applications come from there, you will need to enable Flathub before running it.**
|
||||
|
||||
If you have configured the repository in the `$HOME/.config/flatpaksync/env` file but already have the Flatpaks installed, simply create the `$HOME/.config/flatpaks.user.installed` file to inform the script that the installation is done and start the synchronization.
|
||||
|
|
|
|||
13
modules/bling/installers/flatpaksync.sh
Normal file
13
modules/bling/installers/flatpaksync.sh
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/env bash
|
||||
set -oue pipefail
|
||||
|
||||
SYSTEMD_USER_JOBS_DIR="/usr/lib/systemd/user/"
|
||||
|
||||
mkdir -p "$SYSTEMD_USER_JOBS_DIR"
|
||||
|
||||
chmod +x "$BLING_DIRECTORY"/files/usr/bin/flatpaksync/*
|
||||
|
||||
cp -r "$BLING_DIRECTORY"/files/usr/bin/flatpaksync/* /usr/bin/
|
||||
cp -r "$BLING_DIRECTORY"/files/usr/lib/systemd/user/flatpaksync/* "$SYSTEMD_USER_JOBS_DIR"
|
||||
|
||||
systemctl enable --global flatpaksync.path
|
||||
Loading…
Add table
Add a link
Reference in a new issue