Skip to content

feat: tuitube sync --watch background daemon for auto-syncing subscribed stations #43

@gitcoder89431

Description

@gitcoder89431

Feature

A --watch flag for tuitube sync that runs as a background daemon, polling subscribed stations on a configurable interval and syncing new tracks automatically — no manual tuitube sync required.

Why

Right now, tuitube is a snapshot: you sync once and your library ages. For daily-driver use, users want new uploads from their lofi/jazz/ambient channels to appear automatically — like a podcast client or RSS reader. This is the feature that turns tuitube from a "tool I have to maintain" into a "service that just works."

UX

# Run in background, syncs every 6 hours
tuitube sync --watch --interval 6h

# Or managed by systemd/launchd
# tuitube provides a `tuitube install-service` command that writes the unit file

When new tracks are found:

  • Write to DB as normal
  • Optionally send a desktop notification via notify-send (Linux) or osascript (macOS) — gated by a config flag

Implementation sketch

  1. Parse --interval as time.Duration (default 6h)
  2. Run SyncStations() immediately on start, then time.Sleep(interval) in a loop
  3. PID file at ~/.local/share/tuitube/sync.pid to prevent double-start
  4. Graceful shutdown on SIGTERM/SIGINT
  5. tuitube sync --stop to kill the daemon
  6. tuitube install-service subcommand writes:
    • ~/.config/systemd/user/tuitube-sync.service on Linux
    • ~/Library/LaunchAgents/com.tuitube.sync.plist on macOS

Config integration (see #38)

[sync]
poll_interval = "6h"
notify_on_new_tracks = true

Files likely affected

  • cmd/sync.go — add --watch, --interval, --stop flags
  • New internal/daemon/daemon.go for PID management + signal handling
  • New cmd/installservice.go for the service file writer

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions