Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED][Tutorial?]Working PipeWire on Sway (Wayland)?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
Vvyibaba
n00b
n00b


Joined: 07 Dec 2020
Posts: 3
Location: Spain

PostPosted: Mon Dec 07, 2020 7:25 pm    Post subject: [SOLVED][Tutorial?]Working PipeWire on Sway (Wayland)? Reply with quote

I was wandering around the Gentoo Wiki and stumbled upon the PipeWire article, with a neat explanation on how to install it and replace PulseAudio with it. Tried following the few steps provided but some questions arised.

After the installation and editing pipewire.conf, in order to adapt the .xinit instructions to sway config file I deduced the only thing i need to add is a call to start pipewire whenever i start sway
Code:
exec pipewire
, because i already added dbus to the default runlevel. Am I right when deducing this? Should I make it privileged with something like sudo? (Edit: I changed pipewire, which should work fine to /usr/bin/pipewire to be absolutely sure, and without sudo in order for it to work {See Edit 2})

In order to confirm that I could get away without calling a script to check DBus in the same fashion as it would be done from .xinit, i tried runnig pipewire directly from terminal in order to gain insight on the process and it spitted this ugly errors.
Code:
[E][000515736.124063][dbus.c:319 impl_get_connection()] Failed to connect to system bus: /usr/bin/dbus-launch terminated abnormally with the following error: No protocol specified
Autolaunch error: X11 initialization failed.

[E][000515736.124085][module-portal.c:285 pipewire__module_init()] Failed to connect to system bus
[E][000515736.124101][impl-module.c:281 pw_context_load_module()] "/usr/lib64/pipewire-0.3/libpipewire-module-portal.so": failed to initialize: Cannot allocate memory
[E][000515736.124150][daemon-config.c:202 pw_daemon_config_run_commands()] could not run command load-module: could not load module "libpipewire-module-portal": Cannot allocate memory
[E][000515736.124166][main.c:130 main()] failed to run config commands: Cannot allocate memory
Is pipewire only compatible with X11 or am I doing something wrong? (Edit 2: after trying to fix that error i tried closing and reopening sway and it sort of worked! No PipeWire to be seen on pactl but at least pipewire on the terminal didn't complain about X11 {the sudoed one still did} and graced me with some hints:
Code:
[W][000518859.907373][module-portal.c:143 on_portal_pid_received()] Could not get portal pid: Argument 0 is specified to be of type "uint32", but is actually of type "string"

[W][000518859.910819][pulse-server.c:5343 pw_protocol_pulse_new()] pulse-server 0x55f54c5ecfd0: can't create server for unix:native: Device or resource busy
[W][000518859.912009][module-rtkit.c:502 idle_func()] could not make thread realtime: No such file or directory
[W][000518859.917343][module-rtkit.c:502 idle_func()] could not make thread realtime: No such file or directory
[E][000518859.936054][backend-ofono.c:447 ofono_register_reply()] Register() failed: org.freedesktop.DBus.Error.ServiceUnknown
[W][000518859.944022][context.c:1064 pw_context_load_spa_handle()] context 0x555702f73540: no library for api.jack.device: No such file or directory
[E][000518859.986592][bluez5-dbus.c:1498 get_managed_objects_reply()] GetManagedObjects() failed: org.freedesktop.DBus.Error.ServiceUnknown
[E][000518859.986987][core.c:71 core_event_error()] core 0x5622af281bb0: proxy 0x5622af2b4c60 id:4: bound:-1 seq:4 res:-2 (No such file or directory) msg:"can't create device: No such file or directory"
[E][000518859.987007][media-session.c:1991 core_error()] error id:4 seq:4 res:-2 (No such file or directory): can't create device: No such file or directory
. I think i can get rid of the bluez5 error with some help from the Arch Wiki, but won't work unless you have >=0.3.16 PipeWire)

Given this, pactl wont show PipeWire impersonating PulseAudio but that is something which might get solved with a reboot. I'm gonna try it and come back to tell y'all.

(I'm using the testing branch so maybe that's why trying to get it to work has gone awry)


Last edited by Vvyibaba on Mon Dec 07, 2020 11:05 pm; edited 3 times in total
Back to top
View user's profile Send private message
Vvyibaba
n00b
n00b


Joined: 07 Dec 2020
Posts: 3
Location: Spain

PostPosted: Mon Dec 07, 2020 8:30 pm    Post subject: First steps towards getting it to work Reply with quote

Ok spoilers first: I sort of got it to work, but it is not automated yet.

It seems that i was not right about not needing to activate dbus :lol: . It was plausible since i don't really understand dbus function so i was preacutious about it, which deemed useful.

So what i did was activate dbus manually (seems like the one openrc spawns serves no use) with
Code:
dbus-launch --sh-syntax --exit-with-session
killing pulseaudio from htop and spawning pipewire in a terminal and so, alas, pactl info showed pipewire impersonating pulseaudio successfully (the audio was tested with a web browser and worked flawlessly, apparently).

What bothers me is the fact that previous to doing all of that pipewire wasn't showing on htop despite indicating it on the sway config file. I'll add the dbus command showcased earlier and hopefully it will fix it.

I'll come back if it fixes itself with that, but if not I might consider going to the sway support chat to ask about exec's non-intuitive behaviour (presumably).
Back to top
View user's profile Send private message
Vvyibaba
n00b
n00b


Joined: 07 Dec 2020
Posts: 3
Location: Spain

PostPosted: Mon Dec 07, 2020 10:42 pm    Post subject: Solution! Shell Scripts are the way. Reply with quote

I've actually managed to make it work in some simple steps:

    edit sway config file and add a call to an executable script under waybar definition (if you are not using waybar it might not be necessary)
    Code:
    bar {
       swaybar_command waybar
    }

    exec_always $HOME/.config/sway/./pipewire-start.sh

    create pipewire-start.sh and add
    Code:
    #!/bin/bash
    dbus-launch --sh-syntax --exit-with-session; pulseaudio --kill; pipewire

    make pipewire-start.sh executable and create exit-sway.sh with
    Code:
    #!/bin/bash
    killall pipewire-start.sh pipewire pipewire-pulse; swaymsg exit

    test by rebooting and starting sway. pactl info should display in one line something like
    Code:
    Server Name: PulseAudio (on PipeWire 0.3.17)

    (Optional) make use of exit-sway.sh to cleanup after exiting sway by editing the default exit like so
    Code:
    bindsym $mod+Shift+e exec swaynag -t warning -m 'Do you really want to exit sway? This will end Wayland and PipeWire sessions.' -b 'Yes, exit sway' '$HOME/.config/sway/./exit-sway.sh

    you should not see any pipewire processes if you run htop or ps -aux | grep -i pipewire


The two scripts proposed are not very good code, as they are not flexible enough for changes in behaviour (for example pulseaudio server with autospawn = yes or other pipewire processes) but they will do the work

(EDIT)
Should I try to get thid information to appear on PipeWire's Gentoo Wiki?
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 2895
Location: Rasi, Finland

PostPosted: Tue Dec 08, 2020 5:35 am    Post subject: Re: Solution! Shell Scripts are the way. Reply with quote

Vvyibaba wrote:
Should I try to get thid information to appear on PipeWire's Gentoo Wiki?
Yes, please. :)
_________________
..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
Naib
Watchman
Watchman


Joined: 21 May 2004
Posts: 6022
Location: Removed by Neddy

PostPosted: Thu Dec 10, 2020 10:56 am    Post subject: Reply with quote

The key to this is the need for a user dbus session

Code:
if which dbus-launch >/dev/null && test -z "$DBUS_SESSION_BUS_ADDRESS"; then
       eval `dbus-launch --sh-syntax --exit-with-session`
fi

I have this within my awesomeWM autostart.sh - how you launch this from sway... who knows. I was also puzzled why the system dbus wasn't good enough and hunting around this can be a problem for thos of us who don't use a DM... GNOME/KDE/... all launch a user dbus session so there is a per-user IPC in-use. Since I never needed dbus i never had to do this. The wiki bash snippet is a better way since it checks there isn't a suitable user dbus running.

Once that is done its just a case of executing pipewire by whatever user script you use.


so far I am really liking pipe.

By the way the bluez/jacks errors can be silenced by editing the /etc/pipewire/pipewire.conf file and commenting out the jacks and bluez connections. It appears that even if you do -jacks, -blues aspects of pipewire still build a level of support and thus really complain.
_________________
https://www.otw20.com/ Where you can talk
Quote:
Removed by Chiitoo
Back to top
View user's profile Send private message
Perfect Gentleman
Veteran
Veteran


Joined: 18 May 2014
Posts: 1233

PostPosted: Wed Jan 20, 2021 5:21 pm    Post subject: Reply with quote

there is no need to kill pulseaudio.
Code:
 ~ $ grep -i spawn /etc/pulse/client.conf
autospawn = no
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum