diff --git a/config.go b/config.go index 140cb75..d44d16b 100644 --- a/config.go +++ b/config.go @@ -248,14 +248,15 @@ type MyConfig struct { } `json:"vpn,omitempty"` SimpleVolumePa struct { - Enabled bool `json:"enabled,omitempty"` - Color string `json:"color,omitempty"` - Background string `json:"background,omitempty"` - Font string `json:"font,omitempty"` - FontSize string `json:"font_size,omitempty"` - Symbol string `json:"symbol,omitempty"` - SymbolFont string `json:"symbol_font,omitempty"` - SymbolFontSize string `json:"symbol_font_size,omitempty"` + Enabled bool `json:"enabled,omitempty"` + Color string `json:"color,omitempty"` + Background string `json:"background,omitempty"` + Font string `json:"font,omitempty"` + FontSize string `json:"font_size,omitempty"` + Symbol string `json:"symbol,omitempty"` + SymbolFont string `json:"symbol_font,omitempty"` + SymbolFontSize string `json:"symbol_font_size,omitempty"` + DontExitOnLogin bool `json:"dont_exit_on_login,omitempty"` Separator struct { Left struct { diff --git a/pulseaudio.go b/pulseaudio.go index 4a57db5..b13204b 100644 --- a/pulseaudio.go +++ b/pulseaudio.go @@ -151,7 +151,19 @@ func PaReinit() error { } } - cmd = exec.Command("pulseaudio", "--start") + // PA has annoying feature: socket activation. Sound system must be persistent and available to all users regardless + // of init or other things. They just fail to understand that. Or they fucked up pulseaudio just because they scary + // of security something responsibility. Anyway this is grand design flaw, but we still have to bear with it. + // This setting defines if pulseaudio will be run in manner that allows it to exit is other login detected (how + // they guess it - I do not know). In general case we do not want to allow pa to exit and leave our session without + // audio. + if Conf.SimpleVolumePa.DontExitOnLogin { + // Do not exit on any kind of login/logout events. + cmd = exec.Command("pulseaudio", "--exit-idle-time=-1", "--start") + } else { + // Exit immediately on logout(?). + cmd = exec.Command("pulseaudio", "--exit-idle-time=0", "--start") + } if err := cmd.Run(); err != nil { return fmt.Errorf("unable to initialize pulseaudio server instance: %w", err)