Skip to content

Commit

Permalink
fix(host): Shutdown cleanly on event channel close
Browse files Browse the repository at this point in the history
  • Loading branch information
pdf committed Mar 11, 2024
1 parent 913f0ba commit 1255f41
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions cmd/hyprpanel/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,20 @@ func (h *host) watch(hyprEvtCh <-chan *eventv1.Event) {
return
case <-h.quitCh:
return
case evt := <-hyprEvtCh:
case evt, ok := <-hyprEvtCh:
if !ok || evt == nil {
h.log.Error(`Received from closed hypr event channel`)
return
}
h.log.Trace(`Received hypr event`, `kind`, evt.Kind)
for _, panel := range h.panels {
panel.Notify(evt)
}
case evt := <-h.dbusEvtCh:
case evt, ok := <-h.dbusEvtCh:
if !ok || evt == nil {
h.log.Error(`Received from closed dbus event channel`)
return
}
h.log.Trace(`Received dbus event`, `kind`, evt.Kind)
switch evt.Kind {
case eventv1.EventKind_EVENT_KIND_AUDIO_SINK_VOLUME_ADJUST:
Expand Down Expand Up @@ -329,7 +337,11 @@ func (h *host) watch(hyprEvtCh <-chan *eventv1.Event) {
panel.Notify(evt)
}
}
case evt := <-h.audioEvtCh:
case evt, ok := <-h.audioEvtCh:
if !ok || evt == nil {
h.log.Error(`Received from closed audio event channel`)
return
}
h.log.Trace(`Received audio event`, `kind`, evt.Kind)
for _, panel := range h.panels {
panel.Notify(evt)
Expand Down

0 comments on commit 1255f41

Please sign in to comment.