pipewire: wait for sockets to appear before considering it active
this fixes race around consumers like sysvol starting too early
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# administer with pw-cli, pw-mon, pw-top commands
|
||||
{ config, lib, ... }:
|
||||
{ config, lib, pkgs, ... }:
|
||||
let
|
||||
cfg = config.sane.programs.pipewire;
|
||||
in
|
||||
@@ -34,6 +34,16 @@ in
|
||||
wantedBy = [ "graphical-session.target" ];
|
||||
serviceConfig = {
|
||||
ExecStart = "${cfg.package}/bin/pipewire";
|
||||
ExecStartPost = pkgs.writeShellScript "pipewire-wait-started" ''
|
||||
waitFor() {
|
||||
while [ ! -e "$1" ]; do
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
waitFor "$XDG_RUNTIME_DIR/pipewire-0"
|
||||
waitFor "$XDG_RUNTIME_DIR/pipewire-0-manager"
|
||||
'';
|
||||
ExecStopPost = ''rm -f "$XDG_RUNTIME_DIR/{pipewire-0,pipewire-0.lock,pipewire-0-manager,pipewire-0-manager.lock}"'';
|
||||
Type = "simple";
|
||||
Restart = "always";
|
||||
RestartSec = "5s";
|
||||
@@ -45,6 +55,16 @@ in
|
||||
wantedBy = [ "pipewire.service" ];
|
||||
serviceConfig = {
|
||||
ExecStart = "${cfg.package}/bin/pipewire-pulse";
|
||||
ExecStartPost = pkgs.writeShellScript "pipewire-pulse-wait-started" ''
|
||||
waitFor() {
|
||||
while [ ! -e "$1" ]; do
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
waitFor "$XDG_RUNTIME_DIR/pulse/native"
|
||||
waitFor "$XDG_RUNTIME_DIR/pulse/pid"
|
||||
'';
|
||||
ExecStopPost = ''rm -f "$XDG_RUNTIME_DIR/pulse/{native,pid}"'';
|
||||
Type = "simple";
|
||||
Restart = "always";
|
||||
RestartSec = "5s";
|
||||
|
Reference in New Issue
Block a user