Skip to content

Commit

Permalink
fix: no logout sound
Browse files Browse the repository at this point in the history
  • Loading branch information
zsien committed Jun 20, 2024
1 parent 83b3e45 commit 15fd154
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions sound-theme-player/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ func (m *Manager) Play(theme, event, device string) *dbus.Error {

go func() {
m.player.Volume = cfg.Volume
if device == "" {
device = generateDevice(cfg.Card, cfg.Device)
}
logger.Info("volume: ", m.player.Volume)
m.doPlaySound(theme, event, device)
os.Exit(0)
Expand All @@ -151,10 +154,7 @@ func (m *Manager) PrepareShutdownSound(uid int) *dbus.Error {
return dbusutil.ToError(err)
}

device := "default"
if cfg.Card != "" && cfg.Device != "" {
device = fmt.Sprintf("plughw:CARD=%s,DEV=%s", cfg.Card, cfg.Device)
}
device := generateDevice(cfg.Card, cfg.Device)
shutdownCfg.CanPlay = true
shutdownCfg.Theme = cfg.Theme
shutdownCfg.Event = soundutils.EventSystemShutdown
Expand All @@ -166,6 +166,14 @@ func (m *Manager) PrepareShutdownSound(uid int) *dbus.Error {
return dbusutil.ToError(err)
}

func generateDevice(card, device string) string {
if card != "" && device != "" {
return fmt.Sprintf("plughw:CARD=%s,DEV=%s", card, device)
}

return "default"
}

func (*Manager) GetInterfaceName() string {
return dbusInterface
}
Expand Down

0 comments on commit 15fd154

Please sign in to comment.