diff options
-rw-r--r-- | src/config.nim | 2 | ||||
-rw-r--r-- | src/logger.nim | 2 | ||||
-rw-r--r-- | src/windowmanager.nim | 12 |
3 files changed, 10 insertions, 6 deletions
diff --git a/src/config.nim b/src/config.nim index cd5b802..0181310 100644 --- a/src/config.nim +++ b/src/config.nim @@ -31,4 +31,4 @@ const spawnCustom.initKey( key = "Return", mods = modifier, - command = "st")]
\ No newline at end of file + command = "xterm")]
\ No newline at end of file diff --git a/src/logger.nim b/src/logger.nim index bf878b0..bf32981 100644 --- a/src/logger.nim +++ b/src/logger.nim @@ -1,6 +1,6 @@ import logging -const debug = false # set this to true to get debug messags +const debug = false # set this to true to get debug messages var consoleLog* = newConsoleLogger(fmtStr="kauw/ $time/ $levelname: ") diff --git a/src/windowmanager.nim b/src/windowmanager.nim index 04636a3..5c7fd2c 100644 --- a/src/windowmanager.nim +++ b/src/windowmanager.nim @@ -2,7 +2,7 @@ import x11/[x, xlib], config, /keys, logging, /logger, - tables, os + tables, os, posix type WindowManager* = ref object @@ -12,7 +12,7 @@ type root: Window clients: seq[Window] - keys: Table[cuint, Key] + keys: Table[cuint, keys.Key] # Initialiazation stuff proc initKeybindings (wm: WindowManager) @@ -60,7 +60,7 @@ proc createWindowManager*: WindowManager = root: display.DefaultRootWindow(), clients: @[], - keys: initTable[cuint, Key](1)) + keys: initTable[cuint, keys.Key](1)) # Run window manager proc run* (wm: WindowManager) = @@ -135,7 +135,10 @@ proc initCommands (wm: WindowManager) = proc λcloseWindow (wm: WindowManager) = return proc λnextWindow (wm: WindowManager) = return -proc λspawnCustom (wm: WindowManager, key: Key) = return +proc λspawnCustom (wm: WindowManager, key: keys.Key) = + if fork() == 0: + discard execvp(key.command, nil) + quit QuitSuccess # Error Handlers proc onWMDetected (display: PDisplay, e: PXErrorEvent): cint{.cdecl.} = @@ -217,6 +220,7 @@ proc onButtonPress (wm: WindowManager, e: PXButtonEvent) = return proc onButtonRelease (wm: WindowManager, e: PXButtonEvent) = return proc onMotionNotify (wm: WindowManager, e: PXMotionEvent) = return proc onKeyPress (wm: WindowManager, e: PXKeyEvent) = + lvlDebug.log "key event " & $e.keycode let key = wm.keys[e.keycode] case key.keyfunc: of closeWindow: wm.λcloseWindow() |