Skip to content

Commit 61ed8aa

Browse files
committed
fix: Don't wake up the display if it's turned off
1 parent 449b9d6 commit 61ed8aa

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

display.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ func wakeDisplay(force bool) {
157157
return
158158
}
159159

160+
// Don't try to wake up if the display is turned off.
161+
if config.DisplayMaxBrightness == 0 {
162+
return
163+
}
164+
160165
err := setDisplayBrightness(config.DisplayMaxBrightness)
161166
if err != nil {
162167
fmt.Printf("display wake failed, %s\n", err)
@@ -204,12 +209,14 @@ func watchTsEvents() {
204209
// if they're not already set. This is done separately to the init routine as the "never dim"
205210
// option has the value set to zero, but time.NewTicker only accept positive values.
206211
func startBacklightTickers() {
212+
LoadConfig()
207213
// Don't start the tickers if the display is switched off.
214+
// Set the display to off if that's the case.
208215
if config.DisplayMaxBrightness == 0 {
216+
setDisplayBrightness(0)
209217
return
210218
}
211219

212-
LoadConfig()
213220
if dimTicker == nil && config.DisplayDimAfterSec != 0 {
214221
fmt.Printf("display: dim_ticker has started\n")
215222
dimTicker = time.NewTicker(time.Duration(config.DisplayDimAfterSec) * time.Second)
@@ -244,12 +251,12 @@ func startBacklightTickers() {
244251
func init() {
245252
go func() {
246253
waitCtrlClientConnected()
247-
startBacklightTickers()
248254
fmt.Println("setting initial display contents")
249255
time.Sleep(500 * time.Millisecond)
250256
updateStaticContents()
251257
displayInited = true
252258
fmt.Println("display inited")
259+
startBacklightTickers()
253260
wakeDisplay(true)
254261
requestDisplayUpdate()
255262
}()

0 commit comments

Comments
 (0)