This repository contains a Lua script that configures WirePlumber to automatically pause music playback when headphones are disconnected.
- Detects when headphones are unplugged from the default audio sink.
- Automatically pauses playback using
playerctl.
WirePlumber(Session and Policy Manager for PipeWire)playerctl(Command-line utility to control media players)
-
Clone the repository:
git clone https://github.com/khodekia/pause-on-disconnect.git cd pause-on-disconnect -
Copy the script to your WirePlumber configuration directory:
mkdir -p ~/.config/wireplumber cp pause-on-disconnect.lua ~/.config/wireplumber/
-
Enable the script in WirePlumber: Edit or create the file
~/.config/wireplumber/main.lua.d/50-user-config.luaand add the following line:["pause-on-disconnect.lua"] = true,
-
Restart WirePlumber to apply changes:
systemctl --user restart wireplumber
- Play music using any
MPRIS-compatible media player (e.g., VLC, Spotify). - Disconnect your headphones. Playback will automatically pause.
-
The script uses
playerctlto control playback. Ensureplayerctlis installed:sudo dnf install playerctl
-
This behavior applies only to the default audio sink.
This project is licensed under the MIT License.