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
|
# administer with pw-cli, pw-mon, pw-top commands
|
||||||
{ config, lib, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
let
|
let
|
||||||
cfg = config.sane.programs.pipewire;
|
cfg = config.sane.programs.pipewire;
|
||||||
in
|
in
|
||||||
@@ -34,6 +34,16 @@ in
|
|||||||
wantedBy = [ "graphical-session.target" ];
|
wantedBy = [ "graphical-session.target" ];
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStart = "${cfg.package}/bin/pipewire";
|
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";
|
Type = "simple";
|
||||||
Restart = "always";
|
Restart = "always";
|
||||||
RestartSec = "5s";
|
RestartSec = "5s";
|
||||||
@@ -45,6 +55,16 @@ in
|
|||||||
wantedBy = [ "pipewire.service" ];
|
wantedBy = [ "pipewire.service" ];
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStart = "${cfg.package}/bin/pipewire-pulse";
|
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";
|
Type = "simple";
|
||||||
Restart = "always";
|
Restart = "always";
|
||||||
RestartSec = "5s";
|
RestartSec = "5s";
|
||||||
|
Reference in New Issue
Block a user