Simplify stop logic (closing a RO fd is not worth the added complexity)
This commit is contained in:
parent
93da02bf90
commit
b652c48bd4
@ -2,7 +2,6 @@ package afterlock
|
||||
|
||||
import(
|
||||
"time"
|
||||
"sync"
|
||||
"errors"
|
||||
)
|
||||
|
||||
@ -28,8 +27,6 @@ type AfterLock struct {
|
||||
InitialDelay uint
|
||||
LoopDelay uint
|
||||
keyboardDeviceNode string
|
||||
wg sync.WaitGroup
|
||||
stopFlag *AtomicFlag
|
||||
keypressFlag *AtomicFlag
|
||||
Display Display
|
||||
LockScreen Lockscreen
|
||||
@ -40,7 +37,6 @@ type AfterLock struct {
|
||||
func New(keyboardDeviceNode string) *AfterLock {
|
||||
return &AfterLock{
|
||||
keyboardDeviceNode: keyboardDeviceNode,
|
||||
stopFlag: NewAtomicFlag(false),
|
||||
keypressFlag: NewAtomicFlag(false),
|
||||
}
|
||||
}
|
||||
@ -52,7 +48,6 @@ func New(keyboardDeviceNode string) *AfterLock {
|
||||
func (af *AfterLock) Start() {
|
||||
af.checkStructConfigured()
|
||||
|
||||
af.wg.Add(1)
|
||||
go af.detectKeypresses()
|
||||
|
||||
time.Sleep(time.Duration(af.InitialDelay) * time.Second)
|
||||
@ -83,10 +78,6 @@ func (af *AfterLock) detectKeypresses() {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if af.stopFlag.Get() {
|
||||
af.wg.Done()
|
||||
return
|
||||
}
|
||||
af.keypressFlag.Set(true)
|
||||
}
|
||||
}
|
||||
@ -98,8 +89,6 @@ func (af *AfterLock) hybernateDisplayLoop() {
|
||||
panic(err)
|
||||
}
|
||||
if !screenLocked {
|
||||
af.stopFlag.Set(true)
|
||||
af.wg.Wait()
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user