mirror of https://github.com/jetkvm/kvm.git
fix: the screen doesn't dim or turn off
* Fix for #531 Fix for https://github.com/jetkvm/kvm/issues/531 * typo * Skip processing if lease hasn't changed to avoid unnecessary wake-ups * Add comment to clarify the need to stop the tickers
This commit is contained in:
parent
8d77d75294
commit
a7693df92c
15
display.go
15
display.go
|
@ -339,10 +339,18 @@ func startBacklightTickers() {
|
|||
return
|
||||
}
|
||||
|
||||
if dimTicker == nil && config.DisplayDimAfterSec != 0 {
|
||||
// Stop existing tickers to prevent multiple active instances on repeated calls
|
||||
if dimTicker != nil {
|
||||
dimTicker.Stop()
|
||||
}
|
||||
|
||||
if offTicker != nil {
|
||||
offTicker.Stop()
|
||||
}
|
||||
|
||||
if config.DisplayDimAfterSec != 0 {
|
||||
displayLogger.Info().Msg("dim_ticker has started")
|
||||
dimTicker = time.NewTicker(time.Duration(config.DisplayDimAfterSec) * time.Second)
|
||||
defer dimTicker.Stop()
|
||||
|
||||
go func() {
|
||||
for { //nolint:staticcheck
|
||||
|
@ -354,10 +362,9 @@ func startBacklightTickers() {
|
|||
}()
|
||||
}
|
||||
|
||||
if offTicker == nil && config.DisplayOffAfterSec != 0 {
|
||||
if config.DisplayOffAfterSec != 0 {
|
||||
displayLogger.Info().Msg("off_ticker has started")
|
||||
offTicker = time.NewTicker(time.Duration(config.DisplayOffAfterSec) * time.Second)
|
||||
defer offTicker.Stop()
|
||||
|
||||
go func() {
|
||||
for { //nolint:staticcheck
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"github.com/fsnotify/fsnotify"
|
||||
|
@ -149,6 +150,12 @@ func (c *DHCPClient) loadLeaseFile() error {
|
|||
}
|
||||
|
||||
isFirstLoad := c.lease == nil
|
||||
|
||||
// Skip processing if lease hasn't changed to avoid unnecessary wake-ups.
|
||||
if reflect.DeepEqual(c.lease, lease) {
|
||||
return nil
|
||||
}
|
||||
|
||||
c.lease = lease
|
||||
|
||||
if lease.IPAddress == nil {
|
||||
|
|
Loading…
Reference in New Issue