summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkitty piapiac <kcp@bsd.computer>2020-07-30 11:13:19 -0700
committerkitty piapiac <kcp@bsd.computer>2020-07-30 11:13:19 -0700
commit0f9fbd4d89fbf0fab4d375f0b318ed2ab78e6a79 (patch)
tree7d4992dbbdb4fc12a0b9fe28030e043b6fbce7a2
parenta87e3460be918b491878b151991ece4e5246819e (diff)
(/・・)ノ spawnCustom
alt+enter on default opens xterm
-rw-r--r--src/config.nim2
-rw-r--r--src/logger.nim2
-rw-r--r--src/windowmanager.nim12
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()