Skip to main content

Pause Spotify playback when other apps start making noise on Windows. Automatically resume playback when the other sound finishes.

This mimics default Android functionality, where background music would stop for a duration of a call or alarm and resume afterwards.

Usage

Install

pip install spotify-interlude

Set up Spotify

You'll need to obtain a Development Token from Spotify.

  1. Start by creating an account.
  2. Head to the dashboard and create an App called Interlude on your account.
  3. Copy the client ID and secret. This package will need them to control your Spotify client.
  4. Click 'Edit Settings' and set callback URL to http://localhost:9090. Interlude will start a local server at this address to perform authentication with Spotify web API.

Run Interlude for the first time

$Env:SPOTIFY_SECRET=...
$ENV:SPOTIFY_CLIENT_ID=...
interlude

On the first run, you will be redirected to an authorization page for Spotify at https://accounts.spotify.com. You need to grant necessary permissions on your Spotify account.

Start Spotify and play some music. When you try to play some sounds in Chrome, the music should stop playing.

Configure interlude

You can tweak the behaviour of interlude using command line options:

interlude --help
# Usage: interlude [OPTIONS]
# 
#   Monitor the local Spotify client and apps making foreground noise. If
#   --shortcut-path is specified, create a Windows shortcut with the same
#   options instead.
# 
# Options:
#   --spotify-secret TEXT           Secret from your Spotify App dashboard.
#                                   [env var: SPOTIFY_SECRET; required]
#   --spotify-client-id TEXT        Client Id from your Spotify App dashboard.
#                                   [env var: SPOTIFY_CLIENT_ID; required]
#   -p, --process-name TEXT         Names of the programs which should pause
#                                   Spotify when palying sound.  [default:
#                                   chrome.exe, firefox.exe, Telegram.exe]
#   -d, --device-name TEXT          Name of the Spotify device, in case you have
#                                   multiple connected simultaneously. This can
#                                   be used to pause palyback outside of this
#                                   computer.  [default: SURFACE]
#   --session-refresh-interval FLOAT
#                                   How often to scan for new foreground apps
#                                   (seconds)  [default: 5.0]
#   --warmup-duration FLOAT         Delay between end of foreground sound and
#                                   playback resume.  [default: 2.0]
#   --shortcut-path PATH            Path where a shortcut to Interlude should be
#                                   created.
#   --log-path PATH                 Write logs to this file instead of stdout
#   --log-level TEXT                Minimal level of the logs to display
#                                   [default: INFO]
#   --install-completion [bash|zsh|fish|powershell|pwsh]
#                                   Install completion for the specified shell.
#   --show-completion [bash|zsh|fish|powershell|pwsh]
#                                   Show completion for the specified shell, to
#                                   copy it or customize the installation.
#   --help                          Show this message and exit.

Create shortcut

To easily start interlude, create a shortcut with your desired settings:

interlude --shortcut-path ~/Desktop/Interlude.lnk # add other options as needed

Note: the Spotify secret and client ID will be baked into the shortcut.

Environment file

The CLI parses environment variables, so you can keep secrets etc. out of command line history.

You may find a dotenv file loader handy in PowerShell.

Metadata

Release files for spotify-interlude 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spotify-interlude 0.1.2
File Size Uploaded Provenance
spotify_interlude-0.1.2.tar.gz 8.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for spotify-interlude 0.1.2
File Interpreter ABI Platform
spotify_interlude-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 17.5 kB

Release files / spotify_interlude-0.1.2.tar.gz

Download URL spotify_interlude-0.1.2.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2edd2d579ffc6b958f56407b1cf2019aca2e211ebd5585315b812fbb3f8653a2
BLAKE2b-256 checksum
How to use checksums
15cb7190329f0bcf5f11d1d7c42eb2f84e9a47a277ce6c021082d3cc35ef0358
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.10.6 Linux/5.15.0-1023-azure

Release files / spotify_interlude-0.1.2-py3-none-any.whl

Download URL spotify_interlude-0.1.2-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
542fb58862b4a0015ac5bd0a10c9c891e803dfff5595fc10ace6265730d7d92c
BLAKE2b-256 checksum
How to use checksums
e5fcd9a48f8108a24d68cb5f5b6dbcf7f87c47f5e49f1a3e745926bd832b6396
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.10.6 Linux/5.15.0-1023-azure

Security for spotify-interlude 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page