mirror of
https://github.com/tomasriveral/nixos.git
synced 2026-08-11 18:18:37 +02:00
kdrive: setup sync with desktop
This commit is contained in:
@@ -34,15 +34,13 @@
|
|||||||
CPUWeight = 1; # minimum relative CPU share
|
CPUWeight = 1; # minimum relative CPU share
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
/*
|
|
||||||
systemd.user.timers.kdrive-sync = {
|
systemd.user.timers.kdrive-sync = {
|
||||||
wantedBy = [ "timers.target" ];
|
wantedBy = [ "timers.target" ];
|
||||||
timerConfig = {
|
timerConfig = {
|
||||||
OnBootSec = "1m";
|
OnBootSec = "10m";
|
||||||
OnUnitActiveSec = "5m";
|
OnUnitActiveSec = "1h";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
perSystem = {pkgs, ...}: {
|
perSystem = {pkgs, ...}: {
|
||||||
packages.custom-checkKdrive = pkgs.writeShellApplication {
|
packages.custom-checkKdrive = pkgs.writeShellApplication {
|
||||||
@@ -115,18 +113,25 @@
|
|||||||
runtimeInputs = with pkgs; [
|
runtimeInputs = with pkgs; [
|
||||||
rclone
|
rclone
|
||||||
libnotify
|
libnotify
|
||||||
|
ripgrep
|
||||||
];
|
];
|
||||||
text = ''
|
text = ''
|
||||||
REMOTE_NAME="kdrive"
|
REMOTE_NAME="kdrive"
|
||||||
MOUNT_POINT="/home/tomasr/hdd/kdrive"
|
MOUNT_POINT="/home/tomasr/hdd/kdrive"
|
||||||
|
LOGFILE="/tmp/rclone-bisync.log"
|
||||||
if rclone listremotes | rg "^''${REMOTE_NAME}:"; then
|
rm LOGFILE && touch LOGFILE
|
||||||
|
if rclone --config "$HOME/.config/rclone/rclone.conf" listremotes | rg "^''${REMOTE_NAME}:"; then
|
||||||
echo "Syncing ''${REMOTE_NAME}..."
|
echo "Syncing ''${REMOTE_NAME}..."
|
||||||
rclone bisync "''${REMOTE_NAME}:" "$MOUNT_POINT" &
|
if ! rclone --config "$HOME/.config/rclone/rclone.conf" bisync "$MOUNT_POINT" "$REMOTE_NAME:" --recover > "$LOGFILE" 2>&1; then
|
||||||
|
notify-send "rclone bisync failed" "$(cat $LOGFILE)"
|
||||||
|
echo "rclone bisync failed"
|
||||||
|
cat $LOGFILE
|
||||||
|
cp $LOGFILE "$HOME/hdd/kdrive/logs/$(date +%Y-%m-%d-%H-%M-%S).log"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
notify-send "rclone sync failed" \
|
notify-send "rclone sync failed" \
|
||||||
"Remote ''${REMOTE_NAME} not found.\nConfigure rclone and create the dir ~/kdrive/ or comment out the exec line in hyprland.nix."
|
"Remote ''${REMOTE_NAME} not found.\nConfigure rclone and create the dir ~/kdrive/ or comment out the exec line in hyprland.nix."
|
||||||
echo "Remote ''${REMOTE_NAME} not found. Configure rclone or comment out the exec line in hyprland.nix."
|
echo "Remote ''${REMOTE_NAME} not found. Configure rclone or fix in ~/nixos/modules/applications/kdrive.nix"
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user