Skip to content

Instantly share code, notes, and snippets.

@ajboni
Last active April 14, 2024 23:12
Show Gist options
  • Select an option

  • Save ajboni/a066454e51ea7e758a78e166d03a4a1f to your computer and use it in GitHub Desktop.

Select an option

Save ajboni/a066454e51ea7e758a78e166d03a4a1f to your computer and use it in GitHub Desktop.
Simple Yad Frontend to set Pipewire metadata and other pro audio shortcuts
#!/bin/bash
# Simple Yad Frontend to set Pipewire metadata
# Adapted from this post: https://discourse.ardour.org/t/simple-pipewire-pw-metadata-ui/109207/2
# sudo cat /etc/sudoers.d/cpupower 20:03:16
# user ALL=(ALL) NOPASSWD: /usr/bin/cpupower
quantum=$(pw-metadata -n settings 0 clock.force-quantum | sed -n "s/.*value:'\([^']*\)'.*/\1/p")
rate=$(pw-metadata -n settings 0 clock.force-rate | sed -n "s/.*value:'\([^']*\)'.*/\1/p")
governor=$(cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor | head -1)
governors=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors | sed 's/ /!/g')
IFS='|' read -ra output <<<\
$(yad\
--form --columns=1\
--field="Quantum (buffer):CB" ''!^$quantum!64!128!256!512!1024!2048\
--field="Samples/Rate:CB" ''!^$rate!44100!48000!88200!96000\
--field="CPU Governor:CB" !^$governor\!$governors\
--field="Run qpwgraph:SW" \
--height=128\
--width=480\
--center\
--title="Set PipeWire Metadata"\
--window-icon=preferences\
--text="Pro Audio Shortcuts"\
--text-align=center)\
if ! [[ -z "$output" ]]; then
echo $output
pw-metadata -n settings 0 clock.force-quantum ${output[0]}
pw-metadata -n settings 0 clock.force-rate ${output[1]}
sudo cpupower frequency-set -g ${output[2]}
echo ${output[3]}
fi
# pw-metadata -n settings 2>&1 |\
# yad\
# --text-info\
# --width=540\
# --height=280\
# --center\
# --window-icon=preferences\
# --title="Current PipeWire Metadata Settings"\
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment