ctucx.git: nixfiles

ctucx' nixfiles

commit 355d31ce102d15a7e6673b5a1a11ca821c6853e7
parent 0332cfb7c8bd47e4e56d34dbbcf6e0b3174e4237
Author: Leah (ctucx) <leah@ctu.cx>
Date: Sat, 7 May 2022 14:00:15 +0200

machines/blechbuechse: move keybindungs for yabai from skhd.nix to yabai.nix
2 files changed, 87 insertions(+), 84 deletions(-)
M
machines/blechbuechse/skhd.nix
|
88
++++++++-----------------------------------------------------------------------
M
machines/blechbuechse/yabai.nix
|
83
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
diff --git a/machines/blechbuechse/skhd.nix b/machines/blechbuechse/skhd.nix
@@ -18,22 +18,6 @@ let
     fi
   '';
 
-  toggleFloating = pkgs.writeScript "yabaiToggleFloating.sh" ''
-    #!/usr/bin/env bash
-    PATH=$(eval echo $PATH)
-
-    # Toggle the workspace layout between float and bsp
-    read -r curType index <<< $(echo $(yabai -m query --spaces --space | jq '.type, .index'))
-
-    if [ $curType = '"bsp"' ]; then
-      yabai -m space --layout float
-      osascript -e "display notification \"Change the layout of workspace $index to float\" with title \"yabai\""
-    else
-      yabai -m space --layout bsp
-      osascript -e "display notification \"Change the layout of workspace $index to bsp\" with title \"yabai\""
-    fi
-  '';
-
 in {
 
   home-manager.users.leah.home.packages = [ pkgs.skhd ];

@@ -47,70 +31,16 @@ in {
       # sleep
       lalt - z : pmset sleepnow
 
-      # kill focused window
-      lalt + shift - q : yabai -m window --close
-
-      # float / unfloat window and center on screen
-      lalt - space : yabai -m window --toggle float; yabai -m window --grid 4:4:1:1:2:2
-
-      # enter fullscreen mode for the focused window
-      lalt - f : yabai -m window --toggle zoom-fullscreen
-
-      # change layout of desktop
-      lalt - e : ${toggleFloating}
-
-      # rotate tree
-      lalt - r : yabai -m space --rotate 90
-
-      # change focus (using arrow keys)
-      lalt - left  : yabai -m window --focus west
-      lalt - right : yabai -m window --focus east
-      lalt - down  : yabai -m window --focus south
-      lalt - up    : yabai -m window --focus north
-
-      # move managed window
-      shift + lalt - left  : yabai -m window --warp west
-      shift + lalt - right : yabai -m window --warp east
-      shift + lalt - down  : yabai -m window --warp south
-      shift + lalt - up    : yabai -m window --warp north
-
-      # move between workspaces
-      # when SIP is disabled and scripting-additions are loaded yabai can switch workspaces
-      lalt - 1 : yabai -m space --focus 1
-      lalt - 2 : yabai -m space --focus 2
-      lalt - 3 : yabai -m space --focus 3
-      lalt - 4 : yabai -m space --focus 4
-      lalt - 5 : yabai -m space --focus 5
-      lalt - 6 : yabai -m space --focus 6
-      lalt - 7 : yabai -m space --focus 7
-      lalt - 8 : yabai -m space --focus 8
-      lalt - 9 : yabai -m space --focus 9
-
       # switch between workspaces
-      # when SIP enabled (since yabai can't do it w/o scripting-additions). dont forget to enable the needed keybinds in system settings!
-      #lalt - 1 : ${pkgs.skhd}/bin/skhd -k "ctrl - 1"
-      #lalt - 2 : ${pkgs.skhd}/bin/skhd -k "ctrl - 2"
-      #lalt - 3 : ${pkgs.skhd}/bin/skhd -k "ctrl - 3"
-      #lalt - 4 : ${pkgs.skhd}/bin/skhd -k "ctrl - 4"
-      #lalt - 5 : ${pkgs.skhd}/bin/skhd -k "ctrl - 5"
-      #lalt - 6 : ${pkgs.skhd}/bin/skhd -k "ctrl - 6"
-      #lalt - 7 : ${pkgs.skhd}/bin/skhd -k "ctrl - 7"
-      #lalt - 8 : ${pkgs.skhd}/bin/skhd -k "ctrl - 8"
-      #lalt - 9 : ${pkgs.skhd}/bin/skhd -k "ctrl - 9"
-
-      # go back to previous workspace (kind of like back_and_forth in i3)
-      lalt - 0 : yabai -m space --focus recent
-
-      # move focused window to workspace
-      lalt + shift - 1 : yabai -m window --space 1
-      lalt + shift - 2 : yabai -m window --space 2
-      lalt + shift - 3 : yabai -m window --space 3
-      lalt + shift - 4 : yabai -m window --space 4
-      lalt + shift - 5 : yabai -m window --space 5
-      lalt + shift - 6 : yabai -m window --space 6
-      lalt + shift - 7 : yabai -m window --space 7
-      lalt + shift - 8 : yabai -m window --space 8
-      lalt + shift - 9 : yabai -m window --space 9
+      lalt - 1 : ${pkgs.skhd}/bin/skhd -k "ctrl - 1"
+      lalt - 2 : ${pkgs.skhd}/bin/skhd -k "ctrl - 2"
+      lalt - 3 : ${pkgs.skhd}/bin/skhd -k "ctrl - 3"
+      lalt - 4 : ${pkgs.skhd}/bin/skhd -k "ctrl - 4"
+      lalt - 5 : ${pkgs.skhd}/bin/skhd -k "ctrl - 5"
+      lalt - 6 : ${pkgs.skhd}/bin/skhd -k "ctrl - 6"
+      lalt - 7 : ${pkgs.skhd}/bin/skhd -k "ctrl - 7"
+      lalt - 8 : ${pkgs.skhd}/bin/skhd -k "ctrl - 8"
+      lalt - 9 : ${pkgs.skhd}/bin/skhd -k "ctrl - 9"
     '';
   };
 
diff --git a/machines/blechbuechse/yabai.nix b/machines/blechbuechse/yabai.nix
@@ -3,6 +3,22 @@
 let
   yabai       = pkgs.callPackage ../../pkgs/yabai.nix {};
 
+  toggleFloating = pkgs.writeScript "yabaiToggleFloating.sh" ''
+    #!/usr/bin/env bash
+    PATH=$(eval echo $PATH)
+
+    # Toggle the workspace layout between float and bsp
+    read -r curType index <<< $(echo $(yabai -m query --spaces --space | jq '.type, .index'))
+
+    if [ $curType = '"bsp"' ]; then
+      yabai -m space --layout float
+      osascript -e "display notification \"Change the layout of workspace $index to float\" with title \"yabai\""
+    else
+      yabai -m space --layout bsp
+      osascript -e "display notification \"Change the layout of workspace $index to bsp\" with title \"yabai\""
+    fi
+  '';
+
 in {
 
   environment.etc."sudoers.d/yabai".text = ''

@@ -15,10 +31,10 @@ in {
     # enableScriptingAddition = true;
     package                 = yabai;
     config                  = {
-      layout              = "bsp";
+      layout              = "float";
 
       window_placement    = "second_child";
-      window_topmost      = "on";
+      window_topmost      = "off";
       window_shadow       = "off";
       window_opacity      = "off";
 

@@ -32,10 +48,10 @@ in {
     };
 
     extraConfig = ''
-      sudo yabai --load-sa
+      #sudo yabai --load-sa
 
       # load scripting-additions when Dock.app restarts
-      yabai -m signal --add event=dock_did_restart action="sudo yabai --load-sa"
+      #yabai -m signal --add event=dock_did_restart action="sudo yabai --load-sa"
 
       # fix focus when closing windows
       yabai -m signal --add event=window_destroyed action="yabai -m query --windows --window &> /dev/null || yabai -m window --focus mouse"

@@ -55,7 +71,7 @@ in {
       #yabai -m rule --add app='App Store' manage=off layer=above
 
       #float firefox PiP window
-      yabai -m rule --add label="Firfox PIP" app="^Firefox$" title="^(Picture-in-Picture)$" manage=off layer=above sticky=on
+      #yabai -m rule --add label="Firfox PIP" app="^Firefox$" title="^(Picture-in-Picture)$" manage=off layer=above sticky=on
 
       yabai -m rule --add app='pinentry-mac' manage=off layer=above sticky=on
 

@@ -68,4 +84,61 @@ in {
     '';
   };
 
+  services.skhd = {
+    enable     = true;
+    skhdConfig = ''
+      # kill focused window
+      lalt + shift - q : yabai -m window --close
+
+      # float / unfloat window and center on screen
+      #lalt - space : yabai -m window --toggle float; yabai -m window --grid 4:4:1:1:2:2
+
+      # enter fullscreen mode for the focused window
+      lalt - f : yabai -m window --toggle zoom-fullscreen
+
+      # change layout of desktop
+      lalt - e : ${toggleFloating}
+
+      # rotate tree
+      lalt - r : yabai -m space --rotate 90
+
+      # change focus (using arrow keys)
+      lalt - left  : yabai -m window --focus west
+      lalt - right : yabai -m window --focus east
+      lalt - down  : yabai -m window --focus south
+      lalt - up    : yabai -m window --focus north
+
+      # move managed window
+      shift + lalt - left  : yabai -m window --warp west
+      shift + lalt - right : yabai -m window --warp east
+      shift + lalt - down  : yabai -m window --warp south
+      shift + lalt - up    : yabai -m window --warp north
+
+      # move between workspaces
+      #lalt - 1 : yabai -m space --focus 1
+      #lalt - 2 : yabai -m space --focus 2
+      #lalt - 3 : yabai -m space --focus 3
+      #lalt - 4 : yabai -m space --focus 4
+      #lalt - 5 : yabai -m space --focus 5
+      #lalt - 6 : yabai -m space --focus 6
+      #lalt - 7 : yabai -m space --focus 7
+      #lalt - 8 : yabai -m space --focus 8
+      #lalt - 9 : yabai -m space --focus 9
+
+      # go back to previous workspace (kind of like back_and_forth in i3)
+      lalt - 0 : yabai -m space --focus recent
+
+      # move focused window to workspace
+      lalt + shift - 1 : yabai -m window --space 1
+      lalt + shift - 2 : yabai -m window --space 2
+      lalt + shift - 3 : yabai -m window --space 3
+      lalt + shift - 4 : yabai -m window --space 4
+      lalt + shift - 5 : yabai -m window --space 5
+      lalt + shift - 6 : yabai -m window --space 6
+      lalt + shift - 7 : yabai -m window --space 7
+      lalt + shift - 8 : yabai -m window --space 8
+      lalt + shift - 9 : yabai -m window --space 9
+    '';
+  };
+
 }