mirror of https://github.com/jetkvm/kvm.git
Compare commits
No commits in common. "ce54d101292d55f89de998238708c1d0a2892da3" and "6445628114bd894b0e6502618c93962f28278956" have entirely different histories.
ce54d10129
...
6445628114
28
display.go
28
display.go
|
@ -157,21 +157,20 @@ func wakeDisplay(force bool) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't try to wake up if the display is turned off.
|
|
||||||
if config.DisplayMaxBrightness == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
err := setDisplayBrightness(config.DisplayMaxBrightness)
|
err := setDisplayBrightness(config.DisplayMaxBrightness)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("display wake failed, %s\n", err)
|
fmt.Printf("display wake failed, %s\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.DisplayDimAfterSec != 0 {
|
if config.DisplayDimAfterSec == 0 {
|
||||||
|
dimTicker.Stop()
|
||||||
|
} else {
|
||||||
dimTicker.Reset(time.Duration(config.DisplayDimAfterSec) * time.Second)
|
dimTicker.Reset(time.Duration(config.DisplayDimAfterSec) * time.Second)
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.DisplayOffAfterSec != 0 {
|
if config.DisplayOffAfterSec == 0 {
|
||||||
|
offTicker.Stop()
|
||||||
|
} else {
|
||||||
offTicker.Reset(time.Duration(config.DisplayOffAfterSec) * time.Second)
|
offTicker.Reset(time.Duration(config.DisplayOffAfterSec) * time.Second)
|
||||||
}
|
}
|
||||||
backlightState = 0
|
backlightState = 0
|
||||||
|
@ -210,15 +209,8 @@ func watchTsEvents() {
|
||||||
// option has the value set to zero, but time.NewTicker only accept positive values.
|
// option has the value set to zero, but time.NewTicker only accept positive values.
|
||||||
func startBacklightTickers() {
|
func startBacklightTickers() {
|
||||||
LoadConfig()
|
LoadConfig()
|
||||||
// Don't start the tickers if the display is switched off.
|
|
||||||
// Set the display to off if that's the case.
|
|
||||||
if config.DisplayMaxBrightness == 0 {
|
|
||||||
setDisplayBrightness(0)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if dimTicker == nil && config.DisplayDimAfterSec != 0 {
|
if dimTicker == nil && config.DisplayDimAfterSec != 0 {
|
||||||
fmt.Printf("display: dim_ticker has started\n")
|
fmt.Printf("display: dim_ticker has started.")
|
||||||
dimTicker = time.NewTicker(time.Duration(config.DisplayDimAfterSec) * time.Second)
|
dimTicker = time.NewTicker(time.Duration(config.DisplayDimAfterSec) * time.Second)
|
||||||
defer dimTicker.Stop()
|
defer dimTicker.Stop()
|
||||||
|
|
||||||
|
@ -233,7 +225,7 @@ func startBacklightTickers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if offTicker == nil && config.DisplayOffAfterSec != 0 {
|
if offTicker == nil && config.DisplayOffAfterSec != 0 {
|
||||||
fmt.Printf("display: off_ticker has started\n")
|
fmt.Printf("display: off_ticker has started.")
|
||||||
offTicker = time.NewTicker(time.Duration(config.DisplayOffAfterSec) * time.Second)
|
offTicker = time.NewTicker(time.Duration(config.DisplayOffAfterSec) * time.Second)
|
||||||
defer offTicker.Stop()
|
defer offTicker.Stop()
|
||||||
|
|
||||||
|
@ -256,9 +248,9 @@ func init() {
|
||||||
updateStaticContents()
|
updateStaticContents()
|
||||||
displayInited = true
|
displayInited = true
|
||||||
fmt.Println("display inited")
|
fmt.Println("display inited")
|
||||||
startBacklightTickers()
|
wakeDisplay(false)
|
||||||
wakeDisplay(true)
|
|
||||||
requestDisplayUpdate()
|
requestDisplayUpdate()
|
||||||
|
startBacklightTickers()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
go watchTsEvents()
|
go watchTsEvents()
|
||||||
|
|
Loading…
Reference in New Issue