dotfiles/dot_local/bin/executable_pipewire-launcher

28 lines
919 B
Bash

#!/bin/sh
user=$(id -u)
time=$(date +"%b %d, %Y %T")
wire_log=$XDG_STATE_HOME/wireplumber.log
pipe_log=$XDG_STATE_HOME/pipewire.log
pulse_log=$XDG_STATE_HOME/pipewire-pulse.log
echo "--- $time ---" > "$wire_log"
echo "--- $time ---" > "$pipe_log"
echo "--- $time ---" > "$pulse_log"
# Kill any running pipewire processes
killall -q wireplumber & killall -q pipewire-pulse & killall -q pipewire
# Wait for processes to stop
while pgrep -u "$user" -x wireplumber >/dev/null; do sleep 1; done
while pgrep -u "$user" -x pipewire >/dev/null; do sleep 1; done
while pgrep -u "$user" -x pipewire-pulse >/dev/null; do sleep 1; done
# Wait for xdg-desktop-portal to start
until pgrep -u "$user" -f /usr/lib/xdg-desktop-portal >/dev/null; do sleep 1; done
# Launch pipewire
/usr/bin/wireplumber 2>&1 | tee -a "$wire_log" &
/usr/bin/pipewire 2>&1 | tee -a "$pipe_log" &
/usr/bin/pipewire-pulse 2>&1 | tee -a "$pulse_log" &