592 Words

Reading time 3 min

Slackware Sway and Pipewire

The latest slackpkg upgrade-all broke my sound setup in sway. This is the quickfix.

Sway and pipewire

So I use sway in slackware. Apparently very few other people do that but I like sway. I used to use xmonad and really got into the tiling window manager thing. Excessive mouse use always messes up my wrist and elbow due to an old bicycle injury and a pin in my right elbow. So keyboard is king for me.

Some years back, as the wayland train picked up steam, I ditched xmonad for sway. I like sway better than xmonad, as I never really learned haskell, and configuration as a haskell program was just a bit extra for my taste. Sway works great and does all I want.

Then slackware slowly migrated over to pipewire, and eventually wireplumber. I switched early on thanks to the active discussions over on linuxquestion’s slackware forum, but because I use sway I just resorted to manually starting pipewire, pipewire-pulse, and wireplumber in my sway config.

Everything worked fine until yesterday. My occasional slackpkg update; slackpkg install-new; slackpkg upgrade-all resulted in a system with no sound in my bluetooth headphones. Last night I just switched over to kde to watch a think on a streaming service, but lordy I cannot use KDE…too much mouse, and SUPER-1 doesn’t switch over to my alacritty terminal(s) in my number one workspace, it opens up some settings app or something that I have to (mouse click) out of. Over and over and over again. So no, KDE is not for my fingers’ muscle memory.

So this morning I wasted some time finally figuring out how to start pipewire properly in sway in slackware (which does not use systemd–Yay Slackware’s hard-working bdfl Pat!)

The answer is pretty simple.

I just popped open ~/.bashrc in emacs, and way down at the bottom before I set my PATH, I added the line:

# pipewire?
pipewire-start

The program pipewire-start does exactly the same thing my old manual start stuff did in my sway config file, but with a little more polish. The program is:

#!/bin/sh
# Uncomment the following line if you're worried about the pipewire
# daemons running for the root account:
#[ $(id -u) = 0 ] && exit 0
# Sanity check:
if [ ! -x /usr/bin/daemon -o ! -x /usr/bin/wireplumber -o ! -x /usr/bin/pipewire-pulse -o ! -x /usr/bin/pipewire ]; then
  exit 0
fi
# Leave if pulseaudio is in use:
grep -q '^autospawn *= *yes' /etc/pulse/client.conf && \
 ! grep -q '^daemon-binary *=.*pipewire-start' /etc/pulse/client.conf && exit 0
[ -x /etc/rc.d/rc.pulseaudio ] && exit 0
# Continue only if the user has a seat
if loginctl | grep -q " $USER \+seat" ; then
  # Leave if pipewire is already running
  daemon --pidfiles=~/.run --name=pipewire --running && exit 0
  # Start pipewire:
  daemon -rB --pidfiles=~/.run --name=pipewire /usr/bin/pipewire
  # wait for the pipewire socket
  timeout=100
  while [ $timeout -gt 0 ]; do
    [ -S "$XDG_RUNTIME_DIR"/pipewire-0 ] && break
    sleep 0.2
    timeout=$((timeout-1))
  done
  # start the other daemons
  daemon -rB --pidfiles=~/.run --name=wireplumber /usr/bin/wireplumber
  daemon -rB --pidfiles=~/.run --name=pipewire-pulse /usr/bin/pipewire-pulse
  # wait for the pulse socket
  timeout=100
  while [ $timeout -gt 0 ]; do
    [ -S "$XDG_RUNTIME_DIR"/pulse/native ] && break
    sleep 0.2
    timeout=$((timeout-1))
  done
fi

So that starts pipewire, then wireplumber, then pipewire-pulse, and I can once again get sound in my nifty B&W Px7 S3 headphones.

Now if only I could fix the bluetooth driver bug that requires me to have both my low-power bluetooth keyboard on to get sound without glitching. I guess I can’t have everything.