This script provides a simple command-line interface to manage the sample rate of your PipeWire audio system. It allows you to set custom sample rates, choose from common presets (44.1kHz, 48kHz, 96kHz, 192kHz, 384kHz), reset to the default, and view current PipeWire settings.
- Linux: This script is designed for Linux systems. It may not work on other operating systems.
- PipeWire: This script requires PipeWire to be installed and running.
gum: Charm's interactive CLI tool for the arrow-key menus and styled prompts.install.shinstalls it automatically via your package manager; manual instructions are in charmbracelet/gum.
- Clone the repository and run the installer:
git clone https://github.com/AbrarAbe/pwrate.git
cd pwrate
./install.shThe installer:
- installs
gumif it's missing (viapacman,dnf,yum,apt,zypper,brew,nix, orgo), - links
pwrateinto your$PATH(~/.local/binif it's on your PATH, otherwise/usr/local/bin), - installs the required PipeWire config to
~/.config/pipewire/pipewire.conf.d/(backing up any differing existing file as.bak), - asks before restarting PipeWire so the config takes effect.
Re-running ./install.sh is safe — everything is idempotent. Optional flags: --system installs the config to /etc/pipewire/pipewire.conf.d/ instead (requires root), and --no-restart skips the restart prompt.
Expand for the step-by-step version
- Clone the repository and go into it:
git clone https://github.com/AbrarAbe/pwrate.git
cd pwrate-
Install gum via your package manager (see gum's installation section).
-
Make the script executable (if it's not):
chmod +x pwrate- Link it into your
$PATHso you can run it from anywhere:
sudo ln -s "$PWD/pwrate" /usr/local/bin/pwrate- Install the required PipeWire config:
mkdir -p ~/.config/pipewire/pipewire.conf.d
cp .config/pipewire/pipewire.conf.d/*.conf ~/.config/pipewire/pipewire.conf.d/- Optional: for a system-wide config, copy to
/etc/pipewire/pipewire.conf.d/instead (requires root):
sudo cp .config/pipewire/pipewire.conf.d/*.conf /etc/pipewire/pipewire.conf.d/- Restart PipeWire :
systemctl --user restart pipewireForced rates (what this script sets) bypass clock.allowed-rates, so the script works either way. The config fixes the default behavior: when no rate is forced, PipeWire picks the rate dynamically from clock.allowed-rates, and audio at rates missing from that list gets resampled to an allowed one. The pwrate header always shows the current state (active rate, default rate, allowed rates, quantum). To change the allowed rates later, edit the installed .conf file and restart PipeWire.
Run the script from your terminal: pwrate
pwrate is a single screen: a status panel on top and an arrow-key menu (powered by gum) below it:
- Active rate — what your audio is running at now:
96000 (forced)when a rate is forced, orauto (default 192000)when nothing is forced (in that case PipeWire picks from the allowed list per stream). - Default rate — the
clock.ratevalue used when nothing is forced. - Allowed rates / Quantum — the configured
clock.allowed-ratesandclock.quantum.
Menu options:
- Set custom sample rate: Prompts for a rate in kHz (e.g.
48or44.1). - Set sample rate to 44.1kHz: Sets the sample rate to 44.1 kHz.
- Set sample rate to 48kHz: Sets the sample rate to 48 kHz.
- Set sample rate to 96kHz: Sets the sample rate to 96 kHz.
- Set sample rate to 192kHz: Sets the sample rate to 192 kHz.
- Set sample rate to 384kHz: Sets the sample rate to 384 kHz.
- Reset sample rate to default: Unforces the rate so PipeWire uses its default again.
- Show pactl info: PulseAudio/PipeWire server information (
pactl infoandpactl stat) in a scrollable pager. - Show current PipeWire processes:
pw-top. - Exit: Quit the script.
After any action the menu redraws with the updated status — the confirmation line ("Sample rate set to: …") is followed immediately by the panel showing the new active rate.
The script drives its menus and prompts with gum and interacts with PipeWire using the pw-metadata command to get and set the clock.force-rate setting. The status panel reads clock.force-rate, clock.rate, clock.allowed-rates, and clock.quantum in one pass: a non-zero clock.force-rate is shown as the active (forced) rate, while clock.rate is only displayed as the active rate when nothing is forced. A forced rate applies immediately and bypasses clock.allowed-rates; the allowed list only governs rate selection when nothing is forced. Error handling is included for missing pw-metadata/gum and invalid rate input.
- PipeWire not installed: Ensure PipeWire is installed on your system.
- Permission errors: You may need administrator privileges to run the script, especially when setting the sample rate. Try running with
sudo. - Unexpected output: If the script produces unexpected output, try running
pw-metadata -n settingsdirectly from the command line to see the raw PipeWire settings. This can help you diagnose issues. - Wrong rate when nothing is forced: with
clock.force-rateat 0 (after a reset or reboot), PipeWire picks the rate fromclock.allowed-rates, and rates missing from that list are resampled. Fix the list — see Installation.
See the LICENSE file for details.