File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ import (
11
11
"time"
12
12
13
13
"github.com/sirupsen/logrus"
14
+
15
+ "github.com/charlie0129/batt/smc"
14
16
)
15
17
16
18
var (
@@ -109,6 +111,10 @@ func systemWillSleepCallback() {
109
111
logrus .Errorf ("DisableCharging failed: %v" , err )
110
112
return
111
113
}
114
+ err = smcConn .SetMagSafeLedState (smc .LedOff )
115
+ if err != nil {
116
+ logrus .Errorf ("SetMagSafeLedState failed: %v" , err )
117
+ }
112
118
} else {
113
119
logrus .Debugln ("no maintained charging is in progress, allow sleep" )
114
120
}
@@ -134,6 +140,14 @@ func systemHasPoweredOnCallback() {
134
140
// Use sleep instead of time.After because when the computer sleeps, we
135
141
// actually want the sleep to prolong as well.
136
142
sleep (postSleepLoopDelaySeconds )
143
+
144
+ if config .DisableChargingPreSleep {
145
+ err := smcConn .SetMagSafeLedState (smc .LedOff )
146
+ if err != nil {
147
+ logrus .Errorf ("SetMagSafeLedState failed: %v" , err )
148
+ }
149
+ }
150
+
137
151
wg .Done ()
138
152
}()
139
153
}
You can’t perform that action at this time.
0 commit comments