2.2 KiB
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,jqon the host- Docker (the script reads container logs)
- Root/sudo access (for
docker logs)
Installation
-
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 -
Create a
.envfile from the example:sudo cp .env.example /opt/arr/slskd/scripts/.env sudo nano /opt/arr/slskd/scripts/.env -
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.