AJ Isaacs 15c7640432 Fix idle timer never expiring due to remote user activity
The log activity check matched "Folder contents", "Browse response",
and "search response" patterns which are triggered by remote users
browsing the shared library — not local user activity. This constant
passive traffic kept resetting the idle timer, preventing disconnect.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 13:01:20 -05:00
2026-02-14 22:39:15 -05:00
2026-02-14 22:39:15 -05:00

slskd-auto-disconnect

Automatically disconnects slskd from the Soulseek network after a period of inactivity. Prevents 24/7 file sharing when you forget to disconnect after downloading music.

How it works

A cron job runs the script every 5 minutes. When slskd is connected, the script checks for activity:

  • Active downloads (in progress, queued, or initializing) via the slskd API
  • Recent docker log activity (searches, folder browsing, downloads, connections)

If no activity is detected for the configured timeout (default 30 minutes), slskd is disconnected from the Soulseek network.

Uploads are intentionally not counted as activity — they're what you're trying to avoid. However, if an upload is mid-transfer when the idle threshold is reached, the script will wait for it to finish before disconnecting.

Requirements

  • curl, jq on the host
  • Docker (the script reads container logs)
  • Root/sudo access (for docker logs)

Installation

  1. Copy the script to your server:

    sudo mkdir -p /opt/arr/slskd/scripts
    sudo cp auto-disconnect.sh /opt/arr/slskd/scripts/
    sudo chmod +x /opt/arr/slskd/scripts/auto-disconnect.sh
    
  2. Create a .env file from the example:

    sudo cp .env.example /opt/arr/slskd/scripts/.env
    sudo nano /opt/arr/slskd/scripts/.env
    
  3. Add a cron job (as root):

    sudo crontab -e
    
    */5 * * * * /opt/arr/slskd/scripts/auto-disconnect.sh 2>/dev/null
    

Configuration

The script loads a .env file from its own directory. See .env.example for all available options.

Variable Default Description
SLSKD_URL http://localhost:5030 slskd API base URL
SLSKD_USER slskd slskd web UI username
SLSKD_PASS slskd slskd web UI password
SLSKD_IDLE_TIMEOUT 30 Minutes of inactivity before disconnect
GOTIFY_URL (empty) Gotify server URL for push notifications
GOTIFY_TOKEN (empty) Gotify app token for push notifications

Logs

The script logs disconnect events and errors to auto-disconnect.log in the same directory. The log auto-truncates at 500 lines.

Description
No description provided
Readme 33 KiB
Languages
Shell 100%