diff --git a/cmd/after-lock/after-lock.go b/cmd/after-lock/after-lock.go index 94f8e62..d7cfbe5 100644 --- a/cmd/after-lock/after-lock.go +++ b/cmd/after-lock/after-lock.go @@ -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 -} \ No newline at end of file +} + +func getKeyboardDevNode() string { + devNode := xinput_devnodes.FindKeyboardDevNode() + if devNode == "" { + panic(errors.New("unable to find keyboard device node")) + } + return devNode +}