From 1ff1a0f51255958e83ee7c3f17fd0be8c628fc51 Mon Sep 17 00:00:00 2001 From: kitty piapiac Date: Mon, 10 Aug 2020 01:41:31 -0700 Subject: some stuff --- .gitignore | 3 ++- README.adoc | 4 +--- TODO | 8 +++----- img/kauw.png | Bin 44765 -> 0 bytes src/config.def.nim | 13 ++++++------- src/keys.nim | 19 ------------------- src/layouts.nim | 17 +++++++++++++++++ src/objects.nim | 31 +++++++++++++++++++++++++++++++ src/windowmanager.nim | 21 +++++---------------- 9 files changed, 65 insertions(+), 51 deletions(-) delete mode 100644 img/kauw.png delete mode 100644 src/keys.nim create mode 100644 src/layouts.nim create mode 100644 src/objects.nim diff --git a/.gitignore b/.gitignore index 6ff1669..0541038 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.kra* -*.swp +*.kak* +*.swp* */config.nim kauw \ No newline at end of file diff --git a/README.adoc b/README.adoc index a43471a..5fcc665 100644 --- a/README.adoc +++ b/README.adoc @@ -50,6 +50,4 @@ $ DISPLAY=:1 ./kauw == (.づ◡﹏◡)づ. todo **** see {4}[TODO] -**** - -image::img/kauw.png[kauw] \ No newline at end of file +**** \ No newline at end of file diff --git a/TODO b/TODO index 3728873..d59e06d 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,4 @@ Todo: - [ ] Better config files - [ ] Literally everything!! - [ ] Support for multiple modifiers on keybinding - [ ] Optional title bars? - [ ] Documentation + [ ] Better configuration + [ ] More layouts + [x] Tiling \ No newline at end of file diff --git a/img/kauw.png b/img/kauw.png deleted file mode 100644 index 6a08cc6..0000000 Binary files a/img/kauw.png and /dev/null differ diff --git a/src/config.def.nim b/src/config.def.nim index c72d8e6..d62caf7 100644 --- a/src/config.def.nim +++ b/src/config.def.nim @@ -1,6 +1,6 @@ -import /keys, x11/x +import objects, x11/x -# settings, or something along those lines +# config const # default mod key, run xmodmap to see what the mod keys are on your current keyboard layout # Mod1 is alt and Mod4 is super @@ -12,17 +12,16 @@ const unfocused: "#295eb3", background: "#232323") - init* = @[ - "xsetroot -solid \"" & colours.background & "\""] - # in pixels frameWidth* = 2 + init* = @[ + "xsetroot -solid \"" & colours.background & "\""] + # store keybindings here keybindings*: seq[Key] = @[ # alt + shift + q will close the focused window - initKey( - closeWindow, + initKey( closeWindow, key = "q", mods = modifier or ShiftMask), diff --git a/src/keys.nim b/src/keys.nim deleted file mode 100644 index a56412a..0000000 --- a/src/keys.nim +++ /dev/null @@ -1,19 +0,0 @@ -type - KeyFunc* = enum - closeWindow, - nextWindow, - setMaster, - spawnCustom - - Key* = object - mods*: cuint - key*: string - keyfunc*: KeyFunc - command*: string - -proc initKey* (keyfunc: KeyFunc, mods: cuint, key: string, command = ""): Key = - return Key( - mods: mods, - key: key, - command: command, - keyfunc: keyfunc) \ No newline at end of file diff --git a/src/layouts.nim b/src/layouts.nim new file mode 100644 index 0000000..3de5da4 --- /dev/null +++ b/src/layouts.nim @@ -0,0 +1,17 @@ +import objects, x11/xlib + +proc masterStack* (wm: WindowManager, w: cuint, h: cuint, offset: cuint) = + var + n = cuint wm.clients.len + leftoverPixels = h - ((n-1) * (h div (n-1))) + lastEnd: cint = 0 + + for i in 1..n-1: + var height = (h div (n-1)) + if leftoverPixels > 0: + height += 1 + leftoverPixels -= 1 + + discard wm.display.XMoveResizeWindow(wm.clients[i], cint w div 2, lastEnd, (w div 2)-offset, height-offset) + + lastEnd += cint height \ No newline at end of file diff --git a/src/objects.nim b/src/objects.nim new file mode 100644 index 0000000..ed83fa8 --- /dev/null +++ b/src/objects.nim @@ -0,0 +1,31 @@ +import tables, x11/[x, xlib] + +type + KeyFunc* = enum + closeWindow, + nextWindow, + setMaster, + spawnCustom + + Key* = object + mods*: cuint + key*: string + keyfunc*: KeyFunc + command*: string + + WindowManager* = ref object + display*: PDisplay + screen*: PScreen + colormap*: Colormap + root*: Window + + clients*: seq[Window] + focused*: int + keys*: Table[cuint, objects.Key] + +proc initKey* (keyfunc: KeyFunc, mods: cuint, key: string, command = ""): Key = + return Key( + mods: mods, + key: key, + command: command, + keyfunc: keyfunc) \ No newline at end of file diff --git a/src/windowmanager.nim b/src/windowmanager.nim index de4640c..2eb947e 100644 --- a/src/windowmanager.nim +++ b/src/windowmanager.nim @@ -1,19 +1,8 @@ import x11/[x, xlib], - config, /keys, - logging, /logger, - tables, os, posix - -type - WindowManager* = ref object - display: PDisplay - screen: PScreen - colormap: Colormap - root: Window - - clients: seq[Window] - focused: int - keys: Table[cuint, keys.Key] + config, objects, + logging, logger, + tables, os, posix # Initialiazation stuff proc initKeybindings (wm: WindowManager) @@ -65,7 +54,7 @@ proc createWindowManager*: WindowManager = clients: @[], focused: 0, - keys: initTable[cuint, keys.Key](1)) + keys: initTable[cuint, objects.Key](1)) # Run window manager proc run* (wm: WindowManager) = @@ -160,7 +149,7 @@ proc λsetMaster (wm: WindowManager) = tileWindows wm lvlDebug.log $wm.focused -proc λspawnCustom (wm: WindowManager, key: keys.Key) = +proc λspawnCustom (wm: WindowManager, key: objects.Key) = if fork() == 0: discard execvp(key.command, nil) quit QuitSuccess -- cgit v1.2.3