Compare commits
No commits in common. "642967c9968dc3f6fb15139fc5e25e0a6616c507" and "308f1e23b0c033aa2a39858c3b5f97a09d9b3986" have entirely different histories.
642967c996
...
308f1e23b0
5 changed files with 187 additions and 0 deletions
|
|
@ -31,6 +31,98 @@
|
||||||
tailscale = "/Applications/Tailscale.app/Contents/MacOS/Tailscale";
|
tailscale = "/Applications/Tailscale.app/Contents/MacOS/Tailscale";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
launchd = {
|
||||||
|
enable = true;
|
||||||
|
agents = {
|
||||||
|
|
||||||
|
freetube-sync = {
|
||||||
|
enable = true;
|
||||||
|
config = {
|
||||||
|
Label = "local.home-manager.freetube-sync";
|
||||||
|
ProgramArguments = [
|
||||||
|
"/bin/sh"
|
||||||
|
"-c"
|
||||||
|
''
|
||||||
|
FREETUBE_CONFIG_DIR="$HOME/Library/Application Support/FreeTube"
|
||||||
|
NEXTCLOUD_DIR="$HOME/Nextcloud/Settings/FreeTube"
|
||||||
|
|
||||||
|
# Create directories if they don't exist
|
||||||
|
mkdir -p "$FREETUBE_CONFIG_DIR"
|
||||||
|
mkdir -p "$NEXTCLOUD_DIR"
|
||||||
|
|
||||||
|
# List of database files to sync
|
||||||
|
DB_FILES=("settings.db" "history.db" "playlists.db" "subscriptions.db" "profiles.db")
|
||||||
|
|
||||||
|
# Initial sync if Nextcloud has db files but FreeTube doesn't
|
||||||
|
if [ -n "$(ls $NEXTCLOUD_DIR/*.db 2>/dev/null)" ] && [ ! -n "$(ls $FREETUBE_CONFIG_DIR/*.db 2>/dev/null)" ]; then
|
||||||
|
echo "Performing initial sync from Nextcloud to FreeTube"
|
||||||
|
for DB_FILE in "''${DB_FILES[@]}"; do
|
||||||
|
if [ -f "$NEXTCLOUD_DIR/$DB_FILE" ]; then
|
||||||
|
rsync -av --checksum "$NEXTCLOUD_DIR/$DB_FILE" "$FREETUBE_CONFIG_DIR/$DB_FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
# If Nextcloud is empty but FreeTube has db files, copy to Nextcloud
|
||||||
|
elif [ ! -n "$(ls $NEXTCLOUD_DIR/*.db 2>/dev/null)" ] && [ -n "$(ls $FREETUBE_CONFIG_DIR/*.db 2>/dev/null)" ]; then
|
||||||
|
echo "Performing initial sync from FreeTube to Nextcloud"
|
||||||
|
for DB_FILE in "''${DB_FILES[@]}"; do
|
||||||
|
if [ -f "$FREETUBE_CONFIG_DIR/$DB_FILE" ]; then
|
||||||
|
rsync -av --checksum "$FREETUBE_CONFIG_DIR/$DB_FILE" "$NEXTCLOUD_DIR/$DB_FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
# Process each database file individually
|
||||||
|
for DB_FILE in "''${DB_FILES[@]}"; do
|
||||||
|
FT_PATH="$FREETUBE_CONFIG_DIR/$DB_FILE"
|
||||||
|
NC_PATH="$NEXTCLOUD_DIR/$DB_FILE"
|
||||||
|
|
||||||
|
# Skip if neither file exists
|
||||||
|
if [ ! -f "$FT_PATH" ] && [ ! -f "$NC_PATH" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If only one exists, copy it
|
||||||
|
if [ -f "$FT_PATH" ] && [ ! -f "$NC_PATH" ]; then
|
||||||
|
echo "Copying $DB_FILE from FreeTube to Nextcloud"
|
||||||
|
rsync -av "$FT_PATH" "$NC_PATH"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "$FT_PATH" ] && [ -f "$NC_PATH" ]; then
|
||||||
|
echo "Copying $DB_FILE from Nextcloud to FreeTube"
|
||||||
|
rsync -av "$NC_PATH" "$FT_PATH"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Both files exist, check which is newer
|
||||||
|
if [ "$FT_PATH" -nt "$NC_PATH" ]; then
|
||||||
|
echo "Syncing newer $DB_FILE from FreeTube to Nextcloud"
|
||||||
|
rsync -av --update "$FT_PATH" "$NC_PATH"
|
||||||
|
elif [ "$NC_PATH" -nt "$FT_PATH" ]; then
|
||||||
|
echo "Syncing newer $DB_FILE from Nextcloud to FreeTube"
|
||||||
|
rsync -av --update "$NC_PATH" "$FT_PATH"
|
||||||
|
else
|
||||||
|
# Same modification time, compare checksums
|
||||||
|
echo "Verifying $DB_FILE with checksum comparison"
|
||||||
|
rsync -av --checksum "$NC_PATH" "$FT_PATH"
|
||||||
|
rsync -av --checksum "$FT_PATH" "$NC_PATH"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
''
|
||||||
|
];
|
||||||
|
RunAtLoad = true;
|
||||||
|
StartInterval = 300; # Run every 5 minutes (300 seconds)
|
||||||
|
StandardOutPath =
|
||||||
|
"${config.home.homeDirectory}/Library/Logs/freetube-sync.log";
|
||||||
|
StandardErrorPath =
|
||||||
|
"${config.home.homeDirectory}/Library/Logs/freetube-sync-error.log";
|
||||||
|
EnvironmentVariables = {
|
||||||
|
PATH = "${lib.makeBinPath [ pkgs.rsync pkgs.findutils ]}:$PATH";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
programs = {
|
programs = {
|
||||||
bash = {
|
bash = {
|
||||||
profileExtra = ''
|
profileExtra = ''
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,97 @@ in {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
systemd.user = {
|
||||||
|
services = {
|
||||||
|
freetube-sync = {
|
||||||
|
Unit = {
|
||||||
|
Description = "Sync FreeTube settings with Nextcloud";
|
||||||
|
After = [ "network.target" ];
|
||||||
|
};
|
||||||
|
Service = {
|
||||||
|
Type = "oneshot";
|
||||||
|
ExecStart = "${pkgs.writeShellScript "freetube-sync.sh" ''
|
||||||
|
FREETUBE_CONFIG_DIR="$HOME/.var/app/io.freetubeapp.FreeTube/config/FreeTube"
|
||||||
|
NEXTCLOUD_DIR="$HOME/Nextcloud/Settings/FreeTube"
|
||||||
|
|
||||||
|
# Create directories if they don't exist
|
||||||
|
mkdir -p "$FREETUBE_CONFIG_DIR"
|
||||||
|
mkdir -p "$NEXTCLOUD_DIR"
|
||||||
|
|
||||||
|
# List of database files to sync
|
||||||
|
DB_FILES=("settings.db" "history.db" "playlists.db" "subscriptions.db" "profiles.db")
|
||||||
|
|
||||||
|
# Initial sync if Nextcloud has db files but FreeTube doesn't
|
||||||
|
if [ -n "$(ls -A $NEXTCLOUD_DIR/*.db 2>/dev/null)" ] && [ ! -n "$(ls -A $FREETUBE_CONFIG_DIR/*.db 2>/dev/null)" ]; then
|
||||||
|
echo "Performing initial sync from Nextcloud to FreeTube"
|
||||||
|
for DB_FILE in "''${DB_FILES[@]}"; do
|
||||||
|
if [ -f "$NEXTCLOUD_DIR/$DB_FILE" ]; then
|
||||||
|
rsync -av --checksum "$NEXTCLOUD_DIR/$DB_FILE" "$FREETUBE_CONFIG_DIR/$DB_FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
# If Nextcloud is empty but FreeTube has db files, copy to Nextcloud
|
||||||
|
elif [ ! -n "$(ls -A $NEXTCLOUD_DIR/*.db 2>/dev/null)" ] && [ -n "$(ls -A $FREETUBE_CONFIG_DIR/*.db 2>/dev/null)" ]; then
|
||||||
|
echo "Performing initial sync from FreeTube to Nextcloud"
|
||||||
|
for DB_FILE in "''${DB_FILES[@]}"; do
|
||||||
|
if [ -f "$FREETUBE_CONFIG_DIR/$DB_FILE" ]; then
|
||||||
|
rsync -av --checksum "$FREETUBE_CONFIG_DIR/$DB_FILE" "$NEXTCLOUD_DIR/$DB_FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
# Process each database file individually
|
||||||
|
for DB_FILE in "''${DB_FILES[@]}"; do
|
||||||
|
FT_PATH="$FREETUBE_CONFIG_DIR/$DB_FILE"
|
||||||
|
NC_PATH="$NEXTCLOUD_DIR/$DB_FILE"
|
||||||
|
|
||||||
|
# Skip if neither file exists
|
||||||
|
if [ ! -f "$FT_PATH" ] && [ ! -f "$NC_PATH" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If only one exists, copy it
|
||||||
|
if [ -f "$FT_PATH" ] && [ ! -f "$NC_PATH" ]; then
|
||||||
|
echo "Copying $DB_FILE from FreeTube to Nextcloud"
|
||||||
|
rsync -av "$FT_PATH" "$NC_PATH"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "$FT_PATH" ] && [ -f "$NC_PATH" ]; then
|
||||||
|
echo "Copying $DB_FILE from Nextcloud to FreeTube"
|
||||||
|
rsync -av "$NC_PATH" "$FT_PATH"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Both files exist, check which is newer
|
||||||
|
if [ "$FT_PATH" -nt "$NC_PATH" ]; then
|
||||||
|
echo "Syncing newer $DB_FILE from FreeTube to Nextcloud"
|
||||||
|
rsync -av --update "$FT_PATH" "$NC_PATH"
|
||||||
|
elif [ "$NC_PATH" -nt "$FT_PATH" ]; then
|
||||||
|
echo "Syncing newer $DB_FILE from Nextcloud to FreeTube"
|
||||||
|
rsync -av --update "$NC_PATH" "$FT_PATH"
|
||||||
|
else
|
||||||
|
# Same modification time, compare checksums
|
||||||
|
echo "Verifying $DB_FILE with checksum comparison"
|
||||||
|
rsync -av --checksum "$NC_PATH" "$FT_PATH"
|
||||||
|
rsync -av --checksum "$FT_PATH" "$NC_PATH"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
''}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
timers = {
|
||||||
|
freetube-sync = {
|
||||||
|
Unit = { Description = "Timer for FreeTube settings sync"; };
|
||||||
|
Timer = {
|
||||||
|
OnBootSec = "1m";
|
||||||
|
OnUnitActiveSec = "5m";
|
||||||
|
};
|
||||||
|
Install = { WantedBy = [ "timers.target" ]; };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
xdg = {
|
xdg = {
|
||||||
configFile = {
|
configFile = {
|
||||||
"plasma-workspace/env/ZED_WINDOW_DECORATIONS.sh".text =
|
"plasma-workspace/env/ZED_WINDOW_DECORATIONS.sh".text =
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,7 @@
|
||||||
- com.logseq.Logseq
|
- com.logseq.Logseq
|
||||||
- com.slack.Slack
|
- com.slack.Slack
|
||||||
- dev.deedles.Trayscale
|
- dev.deedles.Trayscale
|
||||||
|
- io.freetubeapp.FreeTube
|
||||||
- io.github.alainm23.planify
|
- io.github.alainm23.planify
|
||||||
- io.github.dweymouth.supersonic
|
- io.github.dweymouth.supersonic
|
||||||
- io.openrct2.OpenRCT2
|
- io.openrct2.OpenRCT2
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@
|
||||||
[
|
[
|
||||||
bitwarden
|
bitwarden
|
||||||
multi-account-containers
|
multi-account-containers
|
||||||
|
libredirect
|
||||||
old-reddit-redirect
|
old-reddit-redirect
|
||||||
ublock-origin
|
ublock-origin
|
||||||
user-agent-string-switcher
|
user-agent-string-switcher
|
||||||
|
|
|
||||||
|
|
@ -208,7 +208,9 @@ in {
|
||||||
casks = [
|
casks = [
|
||||||
"alt-tab"
|
"alt-tab"
|
||||||
"db-browser-for-sqlite"
|
"db-browser-for-sqlite"
|
||||||
|
"dolphin"
|
||||||
"firefox"
|
"firefox"
|
||||||
|
"freetube"
|
||||||
"inkscape"
|
"inkscape"
|
||||||
"iterm2"
|
"iterm2"
|
||||||
"logseq"
|
"logseq"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue