Skip to content

Commit

Permalink
fix(linux): 🐛 don't block sending initial power state sensor update
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuar committed Apr 29, 2024
1 parent f8508e2 commit 5e2100a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/agent/device_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func sensorWorkers() []func(context.Context) chan sensor.Details {
time.Updater,
power.ScreenLockUpdater,
power.LaptopLidUpdater,
power.PowerStateUpdater,
power.StateUpdater,
power.ProfileUpdater,
user.Updater,
system.Versions,
Expand Down
8 changes: 5 additions & 3 deletions internal/linux/power/powerState.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,12 @@ func newPowerState(s powerSignal, v any) *powerStateSensor {
}
}

func PowerStateUpdater(ctx context.Context) chan sensor.Details {
sensorCh := make(chan sensor.Details, 1)
func StateUpdater(ctx context.Context) chan sensor.Details {
sensorCh := make(chan sensor.Details)

sensorCh <- newPowerState(shutdown, false)
go func() {
sensorCh <- newPowerState(shutdown, false)
}()

err := dbusx.NewBusRequest(ctx, dbusx.SystemBus).
Match([]dbus.MatchOption{
Expand Down

0 comments on commit 5e2100a

Please sign in to comment.