1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-08-02 03:28:28 -04:00

gamma: replace login1 scheduler re-calculation with suspend-aware

boottimer
This commit is contained in:
bbedward
2026-07-24 10:49:37 -04:00
parent ea03fb2788
commit 2bafc21229
3 changed files with 9 additions and 25 deletions
+1 -1
View File
@@ -69,7 +69,7 @@ require (
) )
require ( require (
github.com/AvengeMedia/dankgo v0.0.0-20260721162324-38d48943054d github.com/AvengeMedia/dankgo v0.0.0-20260724133713-a4ef23371e05
github.com/atotto/clipboard v0.1.4 // indirect github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/colorprofile v0.4.3 // indirect github.com/charmbracelet/colorprofile v0.4.3 // indirect
+2 -2
View File
@@ -1,7 +1,7 @@
filippo.io/edwards25519 v1.2.0 h1:crnVqOiS4jqYleHd9vaKZ+HKtHfllngJIiOpNpoJsjo= filippo.io/edwards25519 v1.2.0 h1:crnVqOiS4jqYleHd9vaKZ+HKtHfllngJIiOpNpoJsjo=
filippo.io/edwards25519 v1.2.0/go.mod h1:xzAOLCNug/yB62zG1bQ8uziwrIqIuxhctzJT18Q77mc= filippo.io/edwards25519 v1.2.0/go.mod h1:xzAOLCNug/yB62zG1bQ8uziwrIqIuxhctzJT18Q77mc=
github.com/AvengeMedia/dankgo v0.0.0-20260721162324-38d48943054d h1:EZN2x2uAX975Uvw4MByqWaaVTp2fOJrNTl4V4EQbSn8= github.com/AvengeMedia/dankgo v0.0.0-20260724133713-a4ef23371e05 h1:Ij/yzOT8y2HL7V5Rkec1GxJV0rUvhKqfAzyGxVRTk1o=
github.com/AvengeMedia/dankgo v0.0.0-20260721162324-38d48943054d/go.mod h1:7p7cfydr4WM1G6eOPFlANXF3IV5du3FoA4CbDPprHAo= github.com/AvengeMedia/dankgo v0.0.0-20260724133713-a4ef23371e05/go.mod h1:xt8RldAfti0QCWidwYIzsSSoJWsE61WgEhTu2H9UpD4=
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
github.com/ProtonMail/go-crypto v1.4.1 h1:9RfcZHqEQUvP8RzecWEUafnZVtEvrBVL9BiF67IQOfM= github.com/ProtonMail/go-crypto v1.4.1 h1:9RfcZHqEQUvP8RzecWEUafnZVtEvrBVL9BiF67IQOfM=
+6 -22
View File
@@ -12,6 +12,7 @@ import (
"time" "time"
wlclient "github.com/AvengeMedia/DankMaterialShell/core/pkg/go-wayland/wayland/client" wlclient "github.com/AvengeMedia/DankMaterialShell/core/pkg/go-wayland/wayland/client"
"github.com/AvengeMedia/dankgo/boottimer"
"github.com/godbus/dbus/v5" "github.com/godbus/dbus/v5"
"github.com/AvengeMedia/DankMaterialShell/core/internal/errdefs" "github.com/AvengeMedia/DankMaterialShell/core/internal/errdefs"
@@ -23,9 +24,6 @@ import (
const animKelvinStep = 25 const animKelvinStep = 25
// Go timers freeze during suspend; cap sleeps so wall-clock deadlines can't be missed.
const maxScheduleWait = 5 * time.Minute
func NewManager(display wlclient.WaylandDisplay, config Config) (*Manager, error) { func NewManager(display wlclient.WaylandDisplay, config Config) (*Manager, error) {
if err := config.Validate(); err != nil { if err := config.Validate(); err != nil {
return nil, err return nil, err
@@ -752,7 +750,8 @@ func (m *Manager) schedulerLoop() {
m.post(func() { m.applyCurrentTemp("startup") }) m.post(func() { m.applyCurrentTemp("startup") })
} }
var timer *time.Timer timer := boottimer.New(24 * time.Hour)
defer timer.Stop()
for { for {
m.configMutex.RLock() m.configMutex.RLock()
enabled := m.config.Enabled enabled := m.config.Enabled
@@ -761,31 +760,19 @@ func (m *Manager) schedulerLoop() {
now := time.Now() now := time.Now()
m.recalcSchedule(now) m.recalcSchedule(now)
var waitDur time.Duration waitDur := 24 * time.Hour
if enabled { if enabled {
deadline := m.getNextDeadline(now) deadline := m.getNextDeadline(now)
waitDur = time.Until(deadline) if waitDur = time.Until(deadline); waitDur < time.Second {
switch {
case waitDur < time.Second:
waitDur = time.Second waitDur = time.Second
case waitDur > maxScheduleWait:
waitDur = maxScheduleWait
} }
} else {
waitDur = 24 * time.Hour
} }
timer.Reset(waitDur)
if timer != nil {
timer.Stop()
}
timer = time.NewTimer(waitDur)
select { select {
case <-m.stopChan: case <-m.stopChan:
timer.Stop()
return return
case <-m.updateTrigger: case <-m.updateTrigger:
timer.Stop()
m.scheduleMutex.Lock() m.scheduleMutex.Lock()
m.schedule.calcDay = time.Time{} m.schedule.calcDay = time.Time{}
m.scheduleMutex.Unlock() m.scheduleMutex.Unlock()
@@ -1086,14 +1073,11 @@ func (m *Manager) handleResume() {
} }
// Compositor gamma state is unknown after resume; force a resend (#1235) // Compositor gamma state is unknown after resume; force a resend (#1235)
// and re-arm the scheduler timer, which froze during suspend.
m.outputs.Range(func(_ uint32, out *outputState) bool { m.outputs.Range(func(_ uint32, out *outputState) bool {
out.lastTemp = 0 out.lastTemp = 0
return true return true
}) })
m.recalcSchedule(time.Now())
m.applyCurrentTemp("resume") m.applyCurrentTemp("resume")
m.triggerUpdate()
} }
func (m *Manager) triggerUpdate() { func (m *Manager) triggerUpdate() {