Skip to content

Automatically pauses music playback on Linux when headphones are disconnected, Mimics Android/iOS behavior for seamless audio control

Notifications You must be signed in to change notification settings

khodekia/pause-on-disconnect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Pause on Disconnect

This repository contains a Lua script that configures WirePlumber to automatically pause music playback when headphones are disconnected.

Features

  • Detects when headphones are unplugged from the default audio sink.
  • Automatically pauses playback using playerctl.

Requirements

  • WirePlumber (Session and Policy Manager for PipeWire)
  • playerctl (Command-line utility to control media players)

Installation

  1. Clone the repository:

    git clone https://github.com/khodekia/pause-on-disconnect.git
    cd pause-on-disconnect
  2. Copy the script to your WirePlumber configuration directory:

    mkdir -p ~/.config/wireplumber
    cp pause-on-disconnect.lua ~/.config/wireplumber/
  3. Enable the script in WirePlumber: Edit or create the file ~/.config/wireplumber/main.lua.d/50-user-config.lua and add the following line:

    ["pause-on-disconnect.lua"] = true,
  4. Restart WirePlumber to apply changes:

    systemctl --user restart wireplumber

Usage

  • Play music using any MPRIS-compatible media player (e.g., VLC, Spotify).
  • Disconnect your headphones. Playback will automatically pause.

Notes

  • The script uses playerctl to control playback. Ensure playerctl is installed:

    sudo dnf install playerctl
  • This behavior applies only to the default audio sink.

License

This project is licensed under the MIT License.

About

Automatically pauses music playback on Linux when headphones are disconnected, Mimics Android/iOS behavior for seamless audio control

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages