From 3fad9cba18d0a29fddb709b3db93b4f1a0c5d3fa Mon Sep 17 00:00:00 2001
From: dakedres <ramondolive@gmail.com>
Date: Sat, 3 Feb 2024 09:05:49 +0000
Subject: [PATCH] Vinegar changes, multi monitor in bspwm, color changes

---
 hosts/vinegar/configuration.nix         | 27 +++++++++++++++++--------
 hosts/vinegar/home.nix                  | 20 +++++++++++++-----
 modules/bspwm/home.nix                  |  2 +-
 modules/bspwm/scripts/bsp-auto-monitors | 14 +++++++++++++
 modules/bspwm/sxhkdrc                   |  9 ++++++---
 modules/hyprland/home.nix               |  5 +++++
 modules/kitty/colors.nix                |  2 +-
 result                                  |  1 -
 themes/kaolin-dark/default.nix          |  3 +--
 9 files changed, 62 insertions(+), 21 deletions(-)
 create mode 100755 modules/bspwm/scripts/bsp-auto-monitors
 delete mode 120000 result

diff --git a/hosts/vinegar/configuration.nix b/hosts/vinegar/configuration.nix
index 1ca3a7f..10850a3 100644
--- a/hosts/vinegar/configuration.nix
+++ b/hosts/vinegar/configuration.nix
@@ -16,7 +16,7 @@ in {
     <nixos-wsl/modules>
   ];
 
-  home-manager.users."${username}" = {
+  home-manager.users.${username} = {
     imports = helpers.getModules "/home.nix" (import ./modules.nix) ++ [
       ../../common/home.nix
       ./home.nix
@@ -25,6 +25,10 @@ in {
     config.custom.username = username;
   };
 
+  users.users.${username} = {
+    shell = pkgs.fish;
+  };
+
   wsl = {
     enable = true;
     defaultUser  = username;
@@ -37,20 +41,27 @@ in {
   };
 
   services.xserver.enable = true;
-  services.xserver.displayManager.sddm.enable = true;
-  services.xserver.desktopManager.plasma5.enable = true;
+  services.xserver.displayManager.startx.enable = true;
 
-  services.xrdp.enable = true;
-  services.xrdp.defaultWindowManager = "dbus-run-session bspwm";
-  # services.xrdp.defaultWindowManager = "Hyprland";
-  services.xrdp.openFirewall = true;
-  services.xrdp.port = 3390;
+  services.xrdp = {
+    enable = true;
+    defaultWindowManager = "/home/nixos/.xsession";
+  #   defaultWindowManager = "startx";
+    # defaultWindowManager = "startplasma-x11";
+    openFirewall = true;
+    port = 3390;
+    extraConfDirCommands = ''
+    sed -i 's/max_bpp=32/#max_bpp=32\nmax_bpp=128/g' $out/xrdp.ini
+    '';
+  };
+  
 
   environment.systemPackages = [
     pkgs.vscodium
     pkgs.git
     pkgs.wget
     pkgs.micro
+    pkgs.neofetch
   ];
 
   fonts.packages = [
diff --git a/hosts/vinegar/home.nix b/hosts/vinegar/home.nix
index 3203da8..0b3b449 100644
--- a/hosts/vinegar/home.nix
+++ b/hosts/vinegar/home.nix
@@ -4,15 +4,25 @@
   imports =
     # helpers.getModules "/home.nix"  (import ./modules.nix) ++
     [
-    ../../colors/monokai-dark
+    ../../themes/kaolin-dark
     ./start-session/home.nix
     ];
-  custom.wallpaper = ../../wallpapers/blip-blip-blip-blip.jpg;
+  custom.wallpaper = ../../wallpapers/blopies.jpg;
 
   xsession.windowManager.bspwm.extraConfig = ''
   pgrep -x sxhkd > /dev/null || sxhkd &
   '';
 
+  # Workaround for xkb not working properly in xrdp
+  # 
+  # Hypothesis: Xorg starts before a client connects,
+  # so the client's keyboard is added far after
+  # initialization. By adding it to the xsession we set
+  # the xkb map after the client joins 
+  xsession.initExtra = ''
+  setxkbmap -option caps:swapescape,altwin:swap_alt_win
+  '';
+
   home = {
     sessionVariables = {
       EDITOR = "codium";
@@ -21,8 +31,8 @@
       TERM = "kitty";
       FILEMANAGER = "kitty lf";
 
-	    # Tell Electron apps it's wayland
-      NIXOS_OZONE_WL = 1;
+      # Vscodium garbaj
+      DONT_PROMPT_WSL_INSTALL = 1;
     };
 
     sessionPath = [
@@ -42,4 +52,4 @@
   };
 
 
-}
\ No newline at end of file
+}
diff --git a/modules/bspwm/home.nix b/modules/bspwm/home.nix
index 4a904f3..c742c38 100644
--- a/modules/bspwm/home.nix
+++ b/modules/bspwm/home.nix
@@ -56,7 +56,7 @@
       # };
 
       extraConfigEarly = ''
-      bspc monitor -d I II III IV V
+      bsp-auto-monitors
       '';
 
       settings = {
diff --git a/modules/bspwm/scripts/bsp-auto-monitors b/modules/bspwm/scripts/bsp-auto-monitors
new file mode 100755
index 0000000..3578d2f
--- /dev/null
+++ b/modules/bspwm/scripts/bsp-auto-monitors
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+monitors=($(xrandr | grep " connected " | awk '{ print$1 }'))
+monitorcount=${#monitors[*]}
+names=(I II III IV V)
+
+if [ $monitorcount -eq 1 ]; then
+  bspc monitor -d ${names[@]}
+else
+  for((i=0; i<${monitorcount}; i++)); do
+    name=${names[$i]}
+	  bspc monitor ${monitors[$i]} -d ${name}-0 ${name}-1
+  done
+fi
diff --git a/modules/bspwm/sxhkdrc b/modules/bspwm/sxhkdrc
index 252bff1..6da681b 100755
--- a/modules/bspwm/sxhkdrc
+++ b/modules/bspwm/sxhkdrc
@@ -96,9 +96,12 @@ super + {h,j,k,l,Left,Down,Up,Right}
 super + {p,b,comma,period}
 	bspc node -f @{parent,brother,first,second}
 
-# focus the next/previous window in the current desktop
-super + {a,d}
-	bspc node -f {next,prev}.local.!hidden.window
+# # focus the next/previous window in the current desktop
+# super + {a,d}
+# 	bspc node -f {next,prev}.local.!hidden.window
+# Rotate tree
+super + {d,a}
+    bspc node @/ -C {forward,backward}
 
 # focus the next/previous desktop in the current monitor
 super + bracket{left,right}
diff --git a/modules/hyprland/home.nix b/modules/hyprland/home.nix
index 7bbed57..4d25416 100644
--- a/modules/hyprland/home.nix
+++ b/modules/hyprland/home.nix
@@ -8,6 +8,11 @@
   # options.custom.hyprland.enable = lib.mkEnable "hyprland";
 
   config = {
+    # Tell electron apps it's wayland time
+    home.sessionVariables = {
+      "NIXOS_OZONE_WL = 1"
+    }
+
     home.packages = [
       pkgs.swaybg
     ];
diff --git a/modules/kitty/colors.nix b/modules/kitty/colors.nix
index 61d1ede..3a64d3d 100644
--- a/modules/kitty/colors.nix
+++ b/modules/kitty/colors.nix
@@ -8,7 +8,7 @@
     };
   };
 
-  config = {
+  config = lib.mkDefault {
     programs.kitty.settings = with config.custom.colors; {
       # Based on https://github.com/mk12/base16-kitty
 
diff --git a/result b/result
deleted file mode 120000
index 3364c76..0000000
--- a/result
+++ /dev/null
@@ -1 +0,0 @@
-/nix/store/hq65zx7jbxkbn8kqpfhn8gklv9xi6kpx-nixos-system-nixos-24.05.20240117.842d9d8
\ No newline at end of file
diff --git a/themes/kaolin-dark/default.nix b/themes/kaolin-dark/default.nix
index 85b1efd..0ff6205 100644
--- a/themes/kaolin-dark/default.nix
+++ b/themes/kaolin-dark/default.nix
@@ -30,8 +30,7 @@
 
     # The basic colors
     foreground = base07;
-    background = "#000000";
-#     background = base00;
+    background = base00;
 
     selection_foreground = base00;
     selection_background = base07;