From 9bdba2ca39d7356f67c2f8f8c13e0f6a973c460b Mon Sep 17 00:00:00 2001 From: Arpit Chakladar Date: Fri, 13 Mar 2026 20:18:32 +0530 Subject: Using i3 instead of bspwm --- modules/desktop/i3/default.nix | 93 ++++++++++++++++++++++++++++++++++++++ modules/desktop/i3/keybindings.nix | 75 ++++++++++++++++++++++++++++++ 2 files changed, 168 insertions(+) create mode 100644 modules/desktop/i3/default.nix create mode 100644 modules/desktop/i3/keybindings.nix (limited to 'modules/desktop/i3') diff --git a/modules/desktop/i3/default.nix b/modules/desktop/i3/default.nix new file mode 100644 index 0000000..e24f95b --- /dev/null +++ b/modules/desktop/i3/default.nix @@ -0,0 +1,93 @@ +{ + config, + lib, + pkgs, + ... +}: + +{ + config = lib.mkIf config.desktop.enable { + xsession.windowManager.i3.enable = true; + + xsession.windowManager.i3.config = with config.scheme.withHashtag; { + modifier = "Mod4"; # Super + + bars = [ ]; + + gaps = { + inner = 10; + outer = 0; + }; + + window = { + border = 1; + titlebar = false; + }; + + colors = { + focused = { + border = base03; + background = base03; + text = base07; + indicator = base03; + childBorder = base03; + }; + focusedInactive = { + border = base02; + background = base02; + text = base05; + indicator = base02; + childBorder = base02; + }; + unfocused = { + border = base02; + background = base02; + text = base05; + indicator = base02; + childBorder = base02; + }; + }; + + defaultWorkspace = "workspace number 1"; + + window.commands = [ + { + command = "floating enable, sticky enable, resize set 1000 600, move position center"; + criteria = { + class = "floating-termial"; + }; + } + ]; + + focus.followMouse = true; + + startup = [ + # { + # command = "${config.services.polybar.script}"; + # always = true; + # notification = false; + # } + { + command = "xrandr -q | grep -w 'connected' | cut -d' ' -f1 | xargs -I{} i3-msg \"workspace 1 output {}\""; + always = false; + notification = false; + } + { + command = + if config.tools.feh.enable then + "${pkgs.feh}/bin/feh --bg-scale ${../../../assets/skeleton-mage.png}" + else + "xsetroot -solid \"${config.scheme.withHashtag.base00}\""; + always = true; + notification = false; + } + ]; + + keybindings = lib.mkOptionDefault (import ./keybindings.nix { inherit pkgs lib; }); + }; + + xsession.windowManager.i3.extraConfig = '' + exec_always --no-startup-id xrandr -q | grep -w 'connected' | cut -d' ' -f1 | xargs -I{} i3-msg "workspace 1 output {}" + ''; + }; +} diff --git a/modules/desktop/i3/keybindings.nix b/modules/desktop/i3/keybindings.nix new file mode 100644 index 0000000..e61c1b5 --- /dev/null +++ b/modules/desktop/i3/keybindings.nix @@ -0,0 +1,75 @@ +{ pkgs, lib }: + +let + mod = "Mod4"; +in +{ + # --- General Applications --- + "${mod}+r" = "exec rofi -show drun"; + "${mod}+t" = "exec ${pkgs.kitty}/bin/kitty"; + "${mod}+f" = "exec kitty --title 'File Manager' --class floating-termial -e nnn"; + "${mod}+s" = "exec kitty --title 'Keybindings' --class floating-termial -e keybindings.sh"; + "${mod}+q" = "kill"; + + # --- Media / Hardware Keys --- + "XF86MonBrightnessDown" = "exec brightnessctl set 5%-"; + "XF86MonBrightnessUp" = "exec brightnessctl set +5%"; + "XF86AudioLowerVolume" = "exec pamixer --decrease 5"; + "XF86AudioRaiseVolume" = "exec pamixer --increase 5"; + "XF86AudioMute" = "exec pamixer --toggle-mute"; + "XF86AudioPlay" = "exec playerctl play-pause"; + + # --- Window Management (Vim-style) --- + # Focus + "${mod}+h" = "focus left"; + "${mod}+j" = "focus down"; + "${mod}+k" = "focus up"; + "${mod}+l" = "focus right"; + + # Move/Swap + "${mod}+Shift+h" = "move left"; + "${mod}+Shift+j" = "move down"; + "${mod}+Shift+k" = "move up"; + "${mod}+Shift+l" = "move right"; + + # Resize + "${mod}+Control+h" = "resize shrink width 20 px or 20 ppt"; + "${mod}+Control+j" = "resize grow height 20 px or 20 ppt"; + "${mod}+Control+k" = "resize shrink height 20 px or 20 ppt"; + "${mod}+Control+l" = "resize grow width 20 px or 20 ppt"; + + # Layout Modes + "${mod}+n" = "layout tiling"; # Best approx for 'tiled' + "${mod}+d" = "floating toggle"; + "${mod}+m" = "fullscreen toggle"; + + # --- Workspaces --- + # Switch to workspace + "${mod}+1" = "workspace number 1"; + "${mod}+2" = "workspace number 2"; + "${mod}+3" = "workspace number 3"; + "${mod}+4" = "workspace number 4"; + "${mod}+5" = "workspace number 5"; + "${mod}+6" = "workspace number 6"; + "${mod}+7" = "workspace number 7"; + "${mod}+8" = "workspace number 8"; + "${mod}+9" = "workspace number 9"; + "${mod}+0" = "workspace number 10"; + + # Move window to workspace + "${mod}+Shift+1" = "move container to workspace number 1; workspace number 1"; + "${mod}+Shift+2" = "move container to workspace number 2; workspace number 2"; + "${mod}+Shift+3" = "move container to workspace number 3; workspace number 3"; + "${mod}+Shift+4" = "move container to workspace number 4; workspace number 4"; + "${mod}+Shift+5" = "move container to workspace number 5; workspace number 5"; + "${mod}+Shift+6" = "move container to workspace number 6; workspace number 6"; + "${mod}+Shift+7" = "move container to workspace number 7; workspace number 7"; + "${mod}+Shift+8" = "move container to workspace number 8; workspace number 8"; + "${mod}+Shift+9" = "move container to workspace number 9; workspace number 9"; + "${mod}+Shift+0" = "move container to workspace number 10; workspace number 10"; + + # --- Screenshots --- + "${mod}+p" = "exec \"maim -s | xclip -selection clipboard -t image/png\""; + "${mod}+Shift+p" = + "exec \"mkdir -p ~/Pictures/Screenshots && maim -s ~/Pictures/Screenshots/screenshot-$(date +%Y%m%d-%H%M%S).png\""; +} -- cgit v1.2.3