diff options
| author | BossCode45 <boss@tehbox.org> | 2025-05-06 18:00:13 +1200 |
|---|---|---|
| committer | BossCode45 <boss@tehbox.org> | 2025-05-06 18:00:13 +1200 |
| commit | ecc333d03abe308ce47c05345f8f90ae6a01b215 (patch) | |
| tree | 6aa4cc449bf9289c2ac8414931f8a536299c4490 | |
| parent | d1d4a63d4473cd4910b678cf5b385f622186fbd3 (diff) | |
| parent | bc9c5f43f5c8108c3d617716b2c3aeaf553a03e3 (diff) | |
| download | YATwm-ecc333d03abe308ce47c05345f8f90ae6a01b215.tar.gz YATwm-ecc333d03abe308ce47c05345f8f90ae6a01b215.zip | |
Merge branch 'nix'
| -rw-r--r-- | YATwm.nix | 13 | ||||
| -rw-r--r-- | compile_commands.json | 132 | ||||
| -rw-r--r-- | config | 109 | ||||
| -rw-r--r-- | flake.lock | 6 | ||||
| -rw-r--r-- | flake.nix | 18 | ||||
| -rw-r--r-- | makefile | 6 | ||||
| -rw-r--r-- | nix/hm-module.nix | 201 | ||||
| -rw-r--r-- | readme.org | 7 | ||||
| -rw-r--r-- | src/commands.cpp | 43 | ||||
| -rw-r--r-- | src/commands.h | 2 | ||||
| -rw-r--r-- | src/config.cpp | 2 | ||||
| -rw-r--r-- | src/config.h | 2 | ||||
| -rw-r--r-- | src/keybinds.cpp | 55 | ||||
| -rw-r--r-- | src/main.cpp | 30 | ||||
| -rw-r--r-- | test | 2 |
15 files changed, 449 insertions, 179 deletions
@@ -3,7 +3,9 @@ fetchgit, xorg, libnotify, - pkg-config + pkg-config, + inputs, + ... }: @@ -14,7 +16,7 @@ stdenv.mkDerivation { src = fetchgit { url = "https://git.tehbox.org/cgit/boss/YATwm.git/"; rev = "v0.0.1"; - hash = "sha256-c0GIwZFZoaYsq6cK1cPzjxwPZzNg7tyDh44vLFsdMAI="; + hash = "sha256-yQoyXGJE8JrSon/P5uhyN1rRwBH/kz0LCGIly3yNDhg="; }; installPhase = '' @@ -26,5 +28,10 @@ install -D -m 644 config $out/etc/YATwm/config runHook postInstall ''; - buildInputs = [ xorg.libX11 xorg.libXrandr libnotify pkg-config ]; + buildInputs = [ + xorg.libX11 + xorg.libXrandr + libnotify + pkg-config + ]; } diff --git a/compile_commands.json b/compile_commands.json index 3a2baf6..5d777ae 100644 --- a/compile_commands.json +++ b/compile_commands.json @@ -1,49 +1,49 @@ [ { "arguments": [ - "/nix/store/9bv7dcvmfcjnmg5mnqwqlq2wxfn8d7yi-gcc-wrapper-13.2.0/bin/g++", + "/nix/store/888bkaqdpfpx72dd8bdc69qsqlgbhcvf-gcc-wrapper-13.3.0/bin/g++", "-std=c++17", - "-I/nix/store/drrf5w7pcc5q9h4si9i8vm2hclg0zijg-libnotify-0.8.3-dev/include", - "-I/nix/store/a45ri2jgzpv6q36va2y6wq471y88hpnl-gdk-pixbuf-2.42.10-dev/include/gdk-pixbuf-2.0", - "-I/nix/store/s0nl17v1827bl7qyjgkkar90c2a40ykb-glib-2.78.4-dev/include", - "-I/nix/store/s0nl17v1827bl7qyjgkkar90c2a40ykb-glib-2.78.4-dev/include/glib-2.0", - "-I/nix/store/k1qjs35nw1lbssg1l1xpmh0082hy7wl4-glib-2.78.4/lib/glib-2.0/include", + "-I/nix/store/xq34vhc04n55v53xj9hbn0h0vj2ywcv6-libnotify-0.8.3-dev/include", + "-I/nix/store/089kvf479gh1jnapqi296pjn2yvmyplj-gdk-pixbuf-2.42.12-dev/include/gdk-pixbuf-2.0", + "-I/nix/store/5dd834gbg319lfmfwgv54mswcq9k4k57-glib-2.82.1-dev/include", + "-I/nix/store/5dd834gbg319lfmfwgv54mswcq9k4k57-glib-2.82.1-dev/include/glib-2.0", + "-I/nix/store/8mmkgqj0r37s2rlxjvpj8dya7k9gcg77-glib-2.82.1/lib/glib-2.0/include", "-c", "-o", - "build/main.o", - "src/main.cpp" + "build/keybinds.o", + "src/keybinds.cpp" ], "directory": "/home/boss/Documents/Coding/WM/YATwm", - "file": "/home/boss/Documents/Coding/WM/YATwm/src/main.cpp", - "output": "/home/boss/Documents/Coding/WM/YATwm/build/main.o" + "file": "/home/boss/Documents/Coding/WM/YATwm/src/keybinds.cpp", + "output": "/home/boss/Documents/Coding/WM/YATwm/build/keybinds.o" }, { "arguments": [ - "/nix/store/9bv7dcvmfcjnmg5mnqwqlq2wxfn8d7yi-gcc-wrapper-13.2.0/bin/g++", + "/nix/store/888bkaqdpfpx72dd8bdc69qsqlgbhcvf-gcc-wrapper-13.3.0/bin/g++", "-std=c++17", - "-I/nix/store/drrf5w7pcc5q9h4si9i8vm2hclg0zijg-libnotify-0.8.3-dev/include", - "-I/nix/store/a45ri2jgzpv6q36va2y6wq471y88hpnl-gdk-pixbuf-2.42.10-dev/include/gdk-pixbuf-2.0", - "-I/nix/store/s0nl17v1827bl7qyjgkkar90c2a40ykb-glib-2.78.4-dev/include", - "-I/nix/store/s0nl17v1827bl7qyjgkkar90c2a40ykb-glib-2.78.4-dev/include/glib-2.0", - "-I/nix/store/k1qjs35nw1lbssg1l1xpmh0082hy7wl4-glib-2.78.4/lib/glib-2.0/include", + "-I/nix/store/xq34vhc04n55v53xj9hbn0h0vj2ywcv6-libnotify-0.8.3-dev/include", + "-I/nix/store/089kvf479gh1jnapqi296pjn2yvmyplj-gdk-pixbuf-2.42.12-dev/include/gdk-pixbuf-2.0", + "-I/nix/store/5dd834gbg319lfmfwgv54mswcq9k4k57-glib-2.82.1-dev/include", + "-I/nix/store/5dd834gbg319lfmfwgv54mswcq9k4k57-glib-2.82.1-dev/include/glib-2.0", + "-I/nix/store/8mmkgqj0r37s2rlxjvpj8dya7k9gcg77-glib-2.82.1/lib/glib-2.0/include", "-c", "-o", - "build/config.o", - "src/config.cpp" + "build/main.o", + "src/main.cpp" ], "directory": "/home/boss/Documents/Coding/WM/YATwm", - "file": "/home/boss/Documents/Coding/WM/YATwm/src/config.cpp", - "output": "/home/boss/Documents/Coding/WM/YATwm/build/config.o" + "file": "/home/boss/Documents/Coding/WM/YATwm/src/main.cpp", + "output": "/home/boss/Documents/Coding/WM/YATwm/build/main.o" }, { "arguments": [ - "/nix/store/9bv7dcvmfcjnmg5mnqwqlq2wxfn8d7yi-gcc-wrapper-13.2.0/bin/g++", + "/nix/store/888bkaqdpfpx72dd8bdc69qsqlgbhcvf-gcc-wrapper-13.3.0/bin/g++", "-std=c++17", - "-I/nix/store/drrf5w7pcc5q9h4si9i8vm2hclg0zijg-libnotify-0.8.3-dev/include", - "-I/nix/store/a45ri2jgzpv6q36va2y6wq471y88hpnl-gdk-pixbuf-2.42.10-dev/include/gdk-pixbuf-2.0", - "-I/nix/store/s0nl17v1827bl7qyjgkkar90c2a40ykb-glib-2.78.4-dev/include", - "-I/nix/store/s0nl17v1827bl7qyjgkkar90c2a40ykb-glib-2.78.4-dev/include/glib-2.0", - "-I/nix/store/k1qjs35nw1lbssg1l1xpmh0082hy7wl4-glib-2.78.4/lib/glib-2.0/include", + "-I/nix/store/xq34vhc04n55v53xj9hbn0h0vj2ywcv6-libnotify-0.8.3-dev/include", + "-I/nix/store/089kvf479gh1jnapqi296pjn2yvmyplj-gdk-pixbuf-2.42.12-dev/include/gdk-pixbuf-2.0", + "-I/nix/store/5dd834gbg319lfmfwgv54mswcq9k4k57-glib-2.82.1-dev/include", + "-I/nix/store/5dd834gbg319lfmfwgv54mswcq9k4k57-glib-2.82.1-dev/include/glib-2.0", + "-I/nix/store/8mmkgqj0r37s2rlxjvpj8dya7k9gcg77-glib-2.82.1/lib/glib-2.0/include", "-c", "-o", "build/ewmh.o", @@ -55,31 +55,13 @@ }, { "arguments": [ - "/nix/store/9bv7dcvmfcjnmg5mnqwqlq2wxfn8d7yi-gcc-wrapper-13.2.0/bin/g++", - "-std=c++17", - "-I/nix/store/drrf5w7pcc5q9h4si9i8vm2hclg0zijg-libnotify-0.8.3-dev/include", - "-I/nix/store/a45ri2jgzpv6q36va2y6wq471y88hpnl-gdk-pixbuf-2.42.10-dev/include/gdk-pixbuf-2.0", - "-I/nix/store/s0nl17v1827bl7qyjgkkar90c2a40ykb-glib-2.78.4-dev/include", - "-I/nix/store/s0nl17v1827bl7qyjgkkar90c2a40ykb-glib-2.78.4-dev/include/glib-2.0", - "-I/nix/store/k1qjs35nw1lbssg1l1xpmh0082hy7wl4-glib-2.78.4/lib/glib-2.0/include", - "-c", - "-o", - "build/util.o", - "src/util.cpp" - ], - "directory": "/home/boss/Documents/Coding/WM/YATwm", - "file": "/home/boss/Documents/Coding/WM/YATwm/src/util.cpp", - "output": "/home/boss/Documents/Coding/WM/YATwm/build/util.o" - }, - { - "arguments": [ - "/nix/store/9bv7dcvmfcjnmg5mnqwqlq2wxfn8d7yi-gcc-wrapper-13.2.0/bin/g++", + "/nix/store/888bkaqdpfpx72dd8bdc69qsqlgbhcvf-gcc-wrapper-13.3.0/bin/g++", "-std=c++17", - "-I/nix/store/drrf5w7pcc5q9h4si9i8vm2hclg0zijg-libnotify-0.8.3-dev/include", - "-I/nix/store/a45ri2jgzpv6q36va2y6wq471y88hpnl-gdk-pixbuf-2.42.10-dev/include/gdk-pixbuf-2.0", - "-I/nix/store/s0nl17v1827bl7qyjgkkar90c2a40ykb-glib-2.78.4-dev/include", - "-I/nix/store/s0nl17v1827bl7qyjgkkar90c2a40ykb-glib-2.78.4-dev/include/glib-2.0", - "-I/nix/store/k1qjs35nw1lbssg1l1xpmh0082hy7wl4-glib-2.78.4/lib/glib-2.0/include", + "-I/nix/store/xq34vhc04n55v53xj9hbn0h0vj2ywcv6-libnotify-0.8.3-dev/include", + "-I/nix/store/089kvf479gh1jnapqi296pjn2yvmyplj-gdk-pixbuf-2.42.12-dev/include/gdk-pixbuf-2.0", + "-I/nix/store/5dd834gbg319lfmfwgv54mswcq9k4k57-glib-2.82.1-dev/include", + "-I/nix/store/5dd834gbg319lfmfwgv54mswcq9k4k57-glib-2.82.1-dev/include/glib-2.0", + "-I/nix/store/8mmkgqj0r37s2rlxjvpj8dya7k9gcg77-glib-2.82.1/lib/glib-2.0/include", "-c", "-o", "build/IPC.o", @@ -91,13 +73,13 @@ }, { "arguments": [ - "/nix/store/9bv7dcvmfcjnmg5mnqwqlq2wxfn8d7yi-gcc-wrapper-13.2.0/bin/g++", + "/nix/store/888bkaqdpfpx72dd8bdc69qsqlgbhcvf-gcc-wrapper-13.3.0/bin/g++", "-std=c++17", - "-I/nix/store/drrf5w7pcc5q9h4si9i8vm2hclg0zijg-libnotify-0.8.3-dev/include", - "-I/nix/store/a45ri2jgzpv6q36va2y6wq471y88hpnl-gdk-pixbuf-2.42.10-dev/include/gdk-pixbuf-2.0", - "-I/nix/store/s0nl17v1827bl7qyjgkkar90c2a40ykb-glib-2.78.4-dev/include", - "-I/nix/store/s0nl17v1827bl7qyjgkkar90c2a40ykb-glib-2.78.4-dev/include/glib-2.0", - "-I/nix/store/k1qjs35nw1lbssg1l1xpmh0082hy7wl4-glib-2.78.4/lib/glib-2.0/include", + "-I/nix/store/xq34vhc04n55v53xj9hbn0h0vj2ywcv6-libnotify-0.8.3-dev/include", + "-I/nix/store/089kvf479gh1jnapqi296pjn2yvmyplj-gdk-pixbuf-2.42.12-dev/include/gdk-pixbuf-2.0", + "-I/nix/store/5dd834gbg319lfmfwgv54mswcq9k4k57-glib-2.82.1-dev/include", + "-I/nix/store/5dd834gbg319lfmfwgv54mswcq9k4k57-glib-2.82.1-dev/include/glib-2.0", + "-I/nix/store/8mmkgqj0r37s2rlxjvpj8dya7k9gcg77-glib-2.82.1/lib/glib-2.0/include", "-c", "-o", "build/commands.o", @@ -109,20 +91,38 @@ }, { "arguments": [ - "/nix/store/9bv7dcvmfcjnmg5mnqwqlq2wxfn8d7yi-gcc-wrapper-13.2.0/bin/g++", + "/nix/store/888bkaqdpfpx72dd8bdc69qsqlgbhcvf-gcc-wrapper-13.3.0/bin/g++", "-std=c++17", - "-I/nix/store/drrf5w7pcc5q9h4si9i8vm2hclg0zijg-libnotify-0.8.3-dev/include", - "-I/nix/store/a45ri2jgzpv6q36va2y6wq471y88hpnl-gdk-pixbuf-2.42.10-dev/include/gdk-pixbuf-2.0", - "-I/nix/store/s0nl17v1827bl7qyjgkkar90c2a40ykb-glib-2.78.4-dev/include", - "-I/nix/store/s0nl17v1827bl7qyjgkkar90c2a40ykb-glib-2.78.4-dev/include/glib-2.0", - "-I/nix/store/k1qjs35nw1lbssg1l1xpmh0082hy7wl4-glib-2.78.4/lib/glib-2.0/include", + "-I/nix/store/xq34vhc04n55v53xj9hbn0h0vj2ywcv6-libnotify-0.8.3-dev/include", + "-I/nix/store/089kvf479gh1jnapqi296pjn2yvmyplj-gdk-pixbuf-2.42.12-dev/include/gdk-pixbuf-2.0", + "-I/nix/store/5dd834gbg319lfmfwgv54mswcq9k4k57-glib-2.82.1-dev/include", + "-I/nix/store/5dd834gbg319lfmfwgv54mswcq9k4k57-glib-2.82.1-dev/include/glib-2.0", + "-I/nix/store/8mmkgqj0r37s2rlxjvpj8dya7k9gcg77-glib-2.82.1/lib/glib-2.0/include", "-c", "-o", - "build/keybinds.o", - "src/keybinds.cpp" + "build/util.o", + "src/util.cpp" ], "directory": "/home/boss/Documents/Coding/WM/YATwm", - "file": "/home/boss/Documents/Coding/WM/YATwm/src/keybinds.cpp", - "output": "/home/boss/Documents/Coding/WM/YATwm/build/keybinds.o" + "file": "/home/boss/Documents/Coding/WM/YATwm/src/util.cpp", + "output": "/home/boss/Documents/Coding/WM/YATwm/build/util.o" + }, + { + "arguments": [ + "/nix/store/888bkaqdpfpx72dd8bdc69qsqlgbhcvf-gcc-wrapper-13.3.0/bin/g++", + "-std=c++17", + "-I/nix/store/xq34vhc04n55v53xj9hbn0h0vj2ywcv6-libnotify-0.8.3-dev/include", + "-I/nix/store/089kvf479gh1jnapqi296pjn2yvmyplj-gdk-pixbuf-2.42.12-dev/include/gdk-pixbuf-2.0", + "-I/nix/store/5dd834gbg319lfmfwgv54mswcq9k4k57-glib-2.82.1-dev/include", + "-I/nix/store/5dd834gbg319lfmfwgv54mswcq9k4k57-glib-2.82.1-dev/include/glib-2.0", + "-I/nix/store/8mmkgqj0r37s2rlxjvpj8dya7k9gcg77-glib-2.82.1/lib/glib-2.0/include", + "-c", + "-o", + "build/config.o", + "src/config.cpp" + ], + "directory": "/home/boss/Documents/Coding/WM/YATwm", + "file": "/home/boss/Documents/Coding/WM/YATwm/src/config.cpp", + "output": "/home/boss/Documents/Coding/WM/YATwm/build/config.o" } ] @@ -1,51 +1,60 @@ -# This is a comment +# Home manager generated config: + +# Keybinds: +bindmode emacs +quitkey s-g +swapmods +bind "s-0" changeWS 10 +bind "s-1" changeWS 1 +bind "s-2" changeWS 2 +bind "s-3" changeWS 3 +bind "s-4" changeWS 4 +bind "s-5" changeWS 5 +bind "s-6" changeWS 6 +bind "s-7" changeWS 7 +bind "s-8" changeWS 8 +bind "s-9" changeWS 9 +bind "s-E" exit +bind "s-R" reload +bind "s-RET" spawn alacritty +bind "s-S-0" wToWS 10 +bind "s-S-1" wToWS 1 +bind "s-S-2" wToWS 2 +bind "s-S-3" wToWS 3 +bind "s-S-4" wToWS 4 +bind "s-S-5" wToWS 5 +bind "s-S-6" wToWS 6 +bind "s-S-7" wToWS 7 +bind "s-S-8" wToWS 8 +bind "s-S-9" wToWS 9 +bind "s-S-p s" wToWS 11 +bind "s-X" bashSpawn loginctl lock-session && systemctl suspend +bind "s-d" bashSpawn rofi -i -show drun +bind "s-f" fullscreen +bind "s-h" focChange left +bind "s-j" focChange down +bind "s-k" focChange up +bind "s-l" focChange right +bind "s-p s" changeWS 11 +bind "s-r k" spawn kitty +bind "s-t" toggle +bind "s-x" spawn loginctl lock-session + +# Workspaces: +addWorkspace "1: A" 1 +addWorkspace "2: B" 1 +addWorkspace "3: C" 1 +addWorkspace "4: D" 1 +addWorkspace "5: E" 1 +addWorkspace "6: F" 2 1 +addWorkspace "7: G" 2 1 +addWorkspace "8: H" 2 1 +addWorkspace "9: I" 2 1 +addWorkspace "10: J" 2 1 +addWorkspace "S" 1 + + +# Gaps: +gaps 3 +outergaps 3 -# Mainly used for testing -# swapmods - -bind mod+shift+e exit -bind mod+Return spawn alacritty -bind mod+c spawn firefox -bind mod+x spawn loginctl lock-session -bind mod+shift+x bashSpawn loginctl lock-session && systemctl suspend -bind mod+d bashSpawn "rofi -i -show drun" -gaps 10 -outergaps 10 - -bind mod+shift+r reload -bind mod+q kill - -# Tiling -bind mod+t toggle -bind mod+f fullscreen - -# Focus -bind mod+h focChange left -bind mod+j focChange down -bind mod+k focChange up -bind mod+l focChange right - -# Workspaces -addworkspace "1: A" 1 -addworkspace "2: B" 1 -addworkspace "3: C" 1 -addworkspace "4: D" 1 -addworkspace "5: E" 1 -addworkspace "6: F" 2 1 -addworkspace "7: G" 2 1 -addworkspace "8: H" 2 1 -addworkspace "9: I" 2 1 -addworkspace "10: J" 2 1 - -bind mod+1 changeWS 1 -bind mod+2 changeWS 2 -bind mod+3 changeWS 3 -bind mod+4 changeWS 4 -bind mod+5 changeWS 5 -bind mod+6 changeWS 6 -bind mod+7 changeWS 7 -bind mod+8 changeWS 8 -bind mod+9 changeWS 9 -bind mod+0 changeWS 10 - -spawnOnce xss-lock --transfer-sleep-lock -- i3lock -et --nofork
\ No newline at end of file @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1734323986, - "narHash": "sha256-m/lh6hYMIWDYHCAsn81CDAiXoT3gmxXI9J987W5tZrE=", + "lastModified": 1735141468, + "narHash": "sha256-VIAjBr1qGcEbmhLwQJD6TABppPMggzOvqFsqkDoMsAY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "394571358ce82dff7411395829aa6a3aad45b907", + "rev": "4005c3ff7505313cbc21081776ad0ce5dfd7a3ce", "type": "github" }, "original": { @@ -8,17 +8,17 @@ in { devShells.x86_64-linux.default = pkgs.mkShell { - buildInputs = with pkgs; [ - gcc - gnumake - xorg.libX11 - xorg.libXrandr - libnotify - pkg-config - clang-tools + nativeBuildInputs = [ + pkgs.gcc + pkgs.gnumake + pkgs.xorg.libX11 + pkgs.xorg.libXrandr + pkgs.libnotify + pkgs.pkg-config + pkgs.clang-tools ]; }; - packages.x86_64-linux.YATwm = (pkgs.callPackage ./YATwm.nix {}); + packages.x86_64-linux.YATwm = (pkgs.callPackage ./YATwm.nix {inherit inputs;}); packages.x86_64-linux.default = self.packages.x86_64-linux.YATwm; nixosModules.YATwm = import ./nix/module.nix; nixosModules.default = self.nixosModules.YATwm; @@ -32,10 +32,10 @@ remove: r #Files to be compiled $(OBJS_DIR)/main.o: $(SOURCE_FILES) $(SOURCE_HEADERS) $(OBJS_DIR)/ewmh.o: $(SOURCE_DIR)/ewmh.cpp $(SOURCE_DIR)/ewmh.h +$(OBJS_DIR)/command.o: $(SOURCE_DIR)/commands.cpp $(SOURCE_DIR)/commands.h $(SOURCE_DIR)/util.h $(SOURCE_DIR)/error.h $(OBJS_DIR)/util.o: $(SOURCE_DIR)/util.cpp $(SOURCE_DIR)/util.h -$(OBJS_DIR)/commands.o: $(SOURCE_DIR)/commands.cpp $(SOURCE_DIR)/commands.h -$(OBJS_DIR)/config.o: $(SOURCE_DIR)/config.cpp $(SOURCE_DIR)/config.h $(SOURCE_DIR)/commands.h -$(OBJS_DIR)/keybinds.o: $(SOURCE_DIR)/keybinds.cpp $(SOURCE_DIR)/keybinds.h $(SOURCE_DIR)/commands.h +$(OBJS_DIR)/config.o: $(SOURCE_DIR)/config.cpp $(SOURCE_DIR)/config.h +$(OBJS_DIR)/keybinds.o: $(SOURCE_DIR)/keybinds.cpp $(SOURCE_DIR)/keybinds.h $(OBJS_DIR)/ipc.o: $(SOURCE_DIR)/ipc.cpp $(SOURCE_DIR)/ipc.h $(SOURCE_DIR)/commands.h $(SOURCE_DIR)/ewmh.h clean: diff --git a/nix/hm-module.nix b/nix/hm-module.nix index 87b47f2..0db7fd4 100644 --- a/nix/hm-module.nix +++ b/nix/hm-module.nix @@ -1,7 +1,5 @@ { config, lib, pkgs, ... }: - with lib; - let cfg = config.xsession.windowManager.YATwm; in @@ -10,11 +8,210 @@ in options.xsession.windowManager.YATwm = { enable = mkEnableOption "YATwm"; package = mkPackageOption pkgs null { }; + extraConfig = mkOption { + type = types.lines; + default = ""; + example = '' +# Focus +bind mod+h focChange left +bind mod+j focChange down +bind mod+k focChange up +bind mod+l focChange right +''; + description = '' +Extra config lines to be included in the config file +''; + }; + useEmacsBinds = mkOption { + type = types.bool; + default = false; + description = '' +Whether to use the emacs binding system instead of the i3 binding system (only applies if keybinds are set with the home manager module). +Note: Adds the `bindmode emacs` command to the config, and doesn't reset it before any config in extraConfig +''; + }; + quitKey = mkOption { + type = types.str; + default = "mod+g"; + example = "mod+q"; + description = '' +Special key that cannot be bound to which will cancel any in progress keybind (only applies if keybinds are set with the home manager module). +Note: Shouldn't be a key chord. +''; + }; + swapMods = mkOption { + type = types.bool; + default = false; + description = '' +Swap the mod key (windows key) and alt key (meta key) (only applies if keybinds are set with the home manager module). +''; + }; + keybinds = mkOption { + type = types.attrsOf (types.nullOr types.str); + default = {}; + example = '' +{ + "mod+h" = "focChange left"; + "mod+j" = "focChange down"; + "mod+k" = "focChange up"; + "mod+l" = "focChange right"; +} +''; + description = '' +Key combinations and their respective commands to be bound. +Will add a line for each in the form `bind "<keybind>" <command>` (quotes around keybind included) +''; + }; + startup = mkOption { + type = types.listOf (types.submodule { + options = { + command = mkOption { + type = types.str; + default = ""; + example = "nitrogen --restore"; + description = '' +Command to execute. +''; + }; + once = mkOption { + type = types.bool; + default = true; + description = '' +Only execute the command the first time the config is read. +''; + }; + bash = mkOption { + type = types.bool; + default = true; + description = '' +Use bashSpawn instead of spawn. +''; + }; + }; + }); + default = []; + example = '' +[ + { + command = "nitrogen --restore"; + } + { + command = "nm-applet"; + once = false; + bash = false; + } +] +''; + description = '' +List of commands to be executed at startup. +''; + }; + workspaces = mkOption { + type = types.listOf (types.submodule { + options = { + name = mkOption { + type = types.str; + default = "1"; + description = '' +Name for workspace. +''; + }; +# key = mkOption { +# type = stypes.str; +# example = "1"; +# description = '' +# Key that will be used for switching to this monitor. mod+<key> will switch, and mod+shift+<key> will move the currently focused window. +# ''; +# }; + monitorPriorities = mkOption { + type = types.listOf types.int; + default = [1]; + description = '' +List of priorities for which monitor to put the workspace on +''; + }; + }; + }); + default = [ + {name = "1: A";} + {name = "2: B";} + {name = "3: C";} + {name = "4: D";} + {name = "5: E";} + {name = "6: F";} + {name = "7: G";} + {name = "8: H";} + {name = "9: I";} + {name = "10: J";} + ]; + description = '' +List of workspaces to add. +Note: do not chance this while YATwm is running, apart from maybe changing the names, as it can cause issues. +''; + }; + gaps = { + inner = mkOption { + type = types.int; + default = 3; + description = '' +Margins around windows (ends up looking doubled, as all windows have it). +''; + }; + outer = mkOption { + type = types.int; + default = 3; + description = '' +Margin around all windows on an output. +''; + }; + }; }; config = mkIf cfg.enable { home.packages = [ cfg.package ]; xsession.windowManager.command = "${cfg.package}/bin/YATwm"; xsession.enable = true; + xdg.configFile."YATwm/config" = { + text = (strings.concatStringsSep "\n" [ + "# Home manager generated config:\n" + (optionalString (cfg.keybinds != {}) + (strings.concatStrings [ + "# Keybinds:\n" + (optionalString cfg.useEmacsBinds "bindmode emacs\n") + "quitkey ${cfg.quitKey}\n" + (optionalString cfg.swapMods "swapmods\n") + (strings.concatStrings (mapAttrsToList (bind: command: + "bind \"${bind}\" ${command}\n") cfg.keybinds)) + ]) + ) + (optionalString (cfg.workspaces != []) + "# Workspaces:\n" + + (strings.concatStrings (map (workspace: + let + monitorPreferenceString = (strings.concatMapStringsSep " " (x: toString x) workspace.monitorPriorities); + in + "addWorkspace \"${workspace.name}\" ${monitorPreferenceString}\n") cfg.workspaces))) + (optionalString (cfg.startup != []) + "# Startup:\n" + (strings.concatStrings (map (command: + let + spawnCommand = (if command.bash then "bashSpawn" else "spawn") + (optionalString command.once "Once"); + in + "${spawnCommand} ${command.command}\n") cfg.startup))) + "# Gaps:" + "gaps ${toString cfg.gaps.inner}" + "outergaps ${toString cfg.gaps.outer}" + "" + (optionalString (cfg.extraConfig != "") + "# Extra config:\n" + cfg.extraConfig + ) + ]); + onChange = '' + if [ -n "''${DISPLAY+1}" ]; then + if xprop -root | grep YATwm; then + ${cfg.package}/bin/YATwm reload + fi + fi + ''; + }; }; } @@ -7,12 +7,15 @@ This only just works, multiple monitors aren't supported and floating windows ca * Usage instructions ** Installation -*** Pre reqs +*** Nixos +Use the flake. +*** Other distros +**** Pre reqs - ~Xlib~ and ~g++~ and ~libnotify~ to build the program - ~Xephyr~ for the test script - ~rofi~, ~alacritty~, and ~i3lock~ for the default config - The current default config is currently just the configuration that I want to use (this will likely change) -*** Installing and removing +**** Installing and removing - ~make i~ or ~make install~ to install - ~make r~ or ~make remove~ to remove - ~./test~ to test diff --git a/src/commands.cpp b/src/commands.cpp index 5688da4..caa82eb 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -3,15 +3,14 @@ #include "util.h" #include <cctype> +#include <filesystem> #include <iostream> #include <algorithm> -#include <iterator> #include <stdexcept> #include <string> -#include <utility> #include <vector> -#include <regex> #include <cstring> +#include <fstream> using std::cout, std::endl, std::string, std::vector; @@ -20,9 +19,47 @@ const void CommandsModule::echo(const CommandArg* argv) cout << argv[0].str << endl; } +const void CommandsModule::loadFile(const CommandArg* argv) +{ + std::vector<Err> errs; + + string path = cwd + "/" + std::string(argv[0].str); + + std::ifstream file(path); + if(!file.good()) + throw Err(CMD_ERR_NON_FATAL, "File '" + std::string(argv[0].str) + "' doesn't exist"); + + string prevCWD = cwd; + cwd = std::filesystem::path(path).parent_path(); + + cout << "Loading file '" << argv[0].str << "'" << endl; + + int line = 0; + for(string cmd; std::getline(file, cmd);) + { + line++; + if(cmd.size() == 0) + continue; + if(cmd.at(0) == '#') + continue; + try + { + this->runCommand(cmd); + } + catch (Err e) + { + throw Err(e.code, "Error in file '" + std::string(argv[0].str) + "' (line " + std::to_string(line) + "): " + std::to_string(e.code) + "\n\tMessage: " + e.message); + } + } + + cwd = prevCWD; +} + CommandsModule::CommandsModule() { addCommand("echo", &CommandsModule::echo, 1, {STR_REST}, this); + addCommand("loadFile", &CommandsModule::loadFile, 1, {STR_REST}, this); + cwd = std::filesystem::current_path(); } CommandsModule::~CommandsModule() { diff --git a/src/commands.h b/src/commands.h index af4a4a0..4825f1c 100644 --- a/src/commands.h +++ b/src/commands.h @@ -52,6 +52,8 @@ private: std::vector<std::string> splitCommand(std::string command); CommandArg* getCommandArgs(std::vector<std::string>& args, const CommandArgType* argTypes, const int argc); const void echo(const CommandArg* argv); + const void loadFile(const CommandArg* argv); + std::string cwd; public: CommandsModule(); ~CommandsModule(); diff --git a/src/config.cpp b/src/config.cpp index 925e6ea..df8a43d 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -57,7 +57,7 @@ Config::Config(CommandsModule& commandsModule) commandsModule.addCommand("gaps", &Config::gapsCmd, 1, {NUM}, this); commandsModule.addCommand("outergaps", &Config::outerGapsCmd, 1, {NUM}, this); commandsModule.addCommand("logfile", &Config::logFileCmd, 1, {STR_REST}, this); - commandsModule.addCommand("addworkspace", &Config::addWorkspaceCmd, 2, {STR, NUM_ARR_REST}, this); + commandsModule.addCommand("addWorkspace", &Config::addWorkspaceCmd, 2, {STR, NUM_ARR_REST}, this); commandsModule.addCommand("swapmods", &Config::swapSuperAltCmd, 0, {}, this); } diff --git a/src/config.h b/src/config.h index 452db9c..55e4fd3 100644 --- a/src/config.h +++ b/src/config.h @@ -1,8 +1,8 @@ #pragma once -#include "commands.h" #include <X11/X.h> #include <X11/keysym.h> +#include "commands.h" #include <string> #include <vector> diff --git a/src/keybinds.cpp b/src/keybinds.cpp index 235f8c1..1f60a75 100644 --- a/src/keybinds.cpp +++ b/src/keybinds.cpp @@ -168,48 +168,55 @@ const Keybind KeybindsModule::emacsBindMode(string bindString) Keybind bind; bind.modifiers = 0; - const std::regex keyRegex("^(?:([CMs])-)?(?:([CMs])-)?(?:([CMs])-)?([^\\s]|(SPC|ESC|RET|))$"); + //cout << "Adding keybind: '" << bindString << "'" << endl; + + const std::regex keyRegex("^((?:[CMSs]-)*)([^\\s]|(?:SPC|ESC|RET))$"); std::smatch keyMatch; if(std::regex_match(bindString, keyMatch, keyRegex)) { - for (int i = 1; i < 3; i++) + std::ssub_match modifierMatch = keyMatch[1]; + for(std::string modifier : split(modifierMatch, '-')) { - std::ssub_match modifierMatch = keyMatch[i]; - if(modifierMatch.matched) + if(modifier == "s") + { + //cout << "\tModifier: s" << endl; + bind.modifiers |= cfg.swapSuperAlt?Mod1Mask:Mod4Mask; + } + else if(modifier == "M") + { + //cout << "\tModifier: M" << endl; + bind.modifiers |= cfg.swapSuperAlt?Mod4Mask:Mod1Mask; + } + else if(modifier == "C") + { + //cout << "\tModifier: C" << endl; + bind.modifiers |= ControlMask; + } + else if(modifier == "S") { - std::string modifier = modifierMatch.str(); - if(modifier == "s") - { - bind.modifiers |= Mod4Mask >> 3 * cfg.swapSuperAlt; - } - else if(modifier == "M") - { - bind.modifiers |= Mod1Mask << 3 * cfg.swapSuperAlt; - } - else if(modifier == "C") - { - bind.modifiers |= ControlMask; - } + //cout << "\tModifier: S" << endl; + bind.modifiers |= ShiftMask; } } } - KeySym keySym = XStringToKeysym(keyMatch[4].str().c_str()); + KeySym keySym = XStringToKeysym(keyMatch[2].str().c_str()); + //cout << "\tKey: " << keyMatch[2].str() << endl; - if(isUpper(keyMatch[4].str().c_str()) && keySym != NoSymbol) + if(isUpper(keyMatch[2].str().c_str()) && keySym != NoSymbol) { bind.modifiers |= ShiftMask; } if(keySym == NoSymbol) { - if(keyMatch[4].str() == "RET") + if(keyMatch[2].str() == "RET") keySym = XK_Return; - else if(keyMatch[4].str() == "ESC") + else if(keyMatch[2].str() == "ESC") keySym = XK_Escape; - else if(keyMatch[4].str() == "SPC") + else if(keyMatch[2].str() == "SPC") keySym = XK_space; - else if(keyMatch[4].str() == "-") + else if(keyMatch[2].str() == "-") keySym = XK_minus; - else if(keyMatch[4].str() == "+") + else if(keyMatch[2].str() == "+") keySym = XK_plus; else throw Err(CFG_ERR_KEYBIND, "Keybind '" + bindString + "' is invalid"); diff --git a/src/main.cpp b/src/main.cpp index da1ae9b..45e4eba 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,7 +5,6 @@ #include <X11/Xutil.h> #include <X11/extensions/Xrandr.h> -#include <bits/getopt_core.h> #include <libnotify/notification.h> #include <libnotify/notify.h> @@ -18,6 +17,7 @@ #include <iostream> #include <map> #include <ostream> +#include <regex> #include <string> #include <sys/poll.h> #include <sys/select.h> @@ -1029,13 +1029,15 @@ int main(int argc, char** argv) { int versionFlag = 0; bool immediateExit = false; + string configLocation = ""; while(1) { static option long_options[] = {{"version", no_argument, &versionFlag, 1}, + {"config", required_argument, NULL, 'c'}, {0, 0, 0, 0}}; int optionIndex; - char c = getopt_long(argc, argv, "v", long_options, &optionIndex); + char c = getopt_long(argc, argv, "c:v", long_options, &optionIndex); if(c == -1) break; @@ -1047,8 +1049,12 @@ int main(int argc, char** argv) break; //Option had arg break; + case 'c': + configLocation = string(optarg); + break; case 'v': versionFlag = 1; + break; case '?': //Error?? break; @@ -1123,16 +1129,19 @@ int main(int argc, char** argv) std::vector<Err> cfgErr; cout << "Registered commands" << endl; - - char* confDir = getenv("XDG_CONFIG_HOME"); - if(confDir != NULL) - { - cfgErr = cfg.loadFromFile(string(confDir) + "/YATwm/config"); - } + + if(configLocation != "") + cfgErr = cfg.loadFromFile(configLocation); else { - string home = getenv("HOME"); - cfgErr = cfg.loadFromFile(home + "/.config/YATwm/config"); + char* confDir = getenv("XDG_CONFIG_HOME"); + if(confDir != NULL) + cfgErr = cfg.loadFromFile(string(confDir) + "/YATwm/config"); + else + { + string home = getenv("HOME"); + cfgErr = cfg.loadFromFile(home + "/.config/YATwm/config"); + } } cout << "Done config" << endl; @@ -1233,7 +1242,6 @@ int main(int argc, char** argv) } if(ready == -1) { - cout << "E" << endl; log("ERROR"); } } @@ -7,6 +7,6 @@ Xephyr -screen 1600x900+2080+90 :1 & sleep 0.1 -DISPLAY=:1 ./YATwm +DISPLAY=:1 ./YATwm -c config pkill Xephyr |
