Use Xlib code to find a keyboard instead of relying on user config

This commit is contained in:
Kristóf Tóth 2021-10-22 15:15:52 +02:00
parent 9ca48b7bf8
commit 56b65b8449
1 changed files with 12 additions and 3 deletions

View File

@ -1,12 +1,14 @@
package main
import (
"errors"
"kdelsd/afterlock"
"kdelsd/config"
"kdelsd/lockfile"
"kdelsd/xdg/display"
"kdelsd/xdg/keypressdetector"
"kdelsd/xdg/lockscreen"
"kdelsd/xdg/xinput_devnodes"
"log"
"os"
"os/signal"
@ -18,7 +20,6 @@ import (
type afterLockConfig struct {
INITIAL_DELAY int
LOOP_DELAY int
DEV_NODE string
LOCK_PATH string
LOG_PATH string
PRINT_STACKTRACES bool
@ -99,11 +100,19 @@ func initCleanup(lock *lockfile.Lockfile, logfile *os.File) {
}
func buildAfterlock() *afterlock.AfterLock {
al := afterlock.New(configuration.DEV_NODE)
al := afterlock.New(getKeyboardDevNode())
al.InitialDelay = uint(configuration.INITIAL_DELAY)
al.LoopDelay = uint(configuration.LOOP_DELAY)
al.Display = display.Xset{}
al.LockScreen = lockscreen.XDG{}
al.KeypressDetector = keypressdetector.Evdev{}
return al
}
}
func getKeyboardDevNode() string {
devNode := xinput_devnodes.FindKeyboardDevNode()
if devNode == "" {
panic(errors.New("unable to find keyboard device node"))
}
return devNode
}