summaryrefslogtreecommitdiff
path: root/common/modules/x11/bspwm
diff options
context:
space:
mode:
Diffstat (limited to 'common/modules/x11/bspwm')
-rw-r--r--common/modules/x11/bspwm/default.nix179
1 files changed, 179 insertions, 0 deletions
diff --git a/common/modules/x11/bspwm/default.nix b/common/modules/x11/bspwm/default.nix
new file mode 100644
index 0000000..8072fe2
--- /dev/null
+++ b/common/modules/x11/bspwm/default.nix
@@ -0,0 +1,179 @@
+{
+ homeManager,
+ inputs,
+ moduleNameSpace,
+ ...
+}:
+{
+ config,
+ lib,
+ pkgs,
+ ...
+}:
+let
+ cfg = config.${moduleNameSpace}.x11.bspwm;
+ snip = pkgs.writeShellScript "snip" ''
+ case $1 in
+ full)
+ ${pkgs.maim}/bin/maim | ${pkgs.xclip}/bin/xclip -selection clipboard -t image/png
+ ;;
+ selection)
+ ${pkgs.maim}/bin/maim -s | ${pkgs.xclip}/bin/xclip -selection clipboard -t image/png
+ ;;
+ esac
+ '';
+
+ smart-alacritty = pkgs.writeShellScript "smart-alacritty" ''
+ alacritty msg create-window || exec alacritty
+ '';
+
+ smart-ghostty = pkgs.writeShellScript "smart-ghostty" ''
+ ghostty +new-window || exec ghostty
+ '';
+
+ terminal =
+ if config.beeMods.terminal.default == "alacritty" then
+ "${smart-alacritty}"
+ else if config.beeMods.terminal.default == "ghostty" then
+ "${smart-ghostty}"
+ else
+ "st";
+in
+{
+ options.${moduleNameSpace}.x11.bspwm = {
+ enable = lib.mkEnableOption "bspwm setup";
+ };
+
+ config = lib.mkIf cfg.enable (
+ if homeManager then
+ {
+ xsession.windowManager.bspwm = {
+ enable = true;
+ monitors = {
+ "eDP" = [
+ "1"
+ "2"
+ "3"
+ "4"
+ "5"
+ "6"
+ "7"
+ "8"
+ "9"
+ ];
+ };
+
+ rules = {
+ "Alacritty" = {
+ desktop = "^1";
+ follow = true;
+ };
+ "ghostty" = {
+ desktop = "^1";
+ follow = true;
+ };
+ "zen" = {
+ desktop = "^2";
+ follow = true;
+ };
+ "firefox" = {
+ desktop = "^2";
+ follow = true;
+ };
+ "vesktop" = {
+ desktop = "^3";
+ follow = true;
+ };
+ "discord" = {
+ desktop = "^3";
+ follow = true;
+ };
+ "steam" = {
+ desktop = "^4";
+ follow = true;
+ };
+ };
+
+ settings = {
+ border_width = 2;
+ window_gap = 5;
+ split_ratio = 0.55;
+ click_to_focus = "any";
+ pointer_modifier = "mod4";
+ pointer_action1 = "move";
+ pointer_action2 = "resize_side";
+ pointer_action3 = "resize_corner";
+ focus_follows_pointer = true;
+ };
+
+ extraConfig = lib.optionalString config.beeMods.matugen.enable ''
+ [ -f ~/.config/bspwm/colors ] && . ~/.config/bspwm/colors
+ '';
+
+ startupPrograms = [
+ "feh --no-fehbg --bg-fill $(rg wallpaper ~/.config/beeSettings | cut -d'=' -f2)"
+ "xsetroot -cursor_name left_ptr"
+ "${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1"
+ "gnome-keyring-daemon --start --components=secrets,ssh,pkcs11"
+ "xrandr --output eDP --set TearFree on"
+ ];
+ };
+
+ services.sxhkd = {
+ enable = true;
+ keybindings = {
+ "super + Return" = terminal;
+ "super + r" = "pkill -USR1 -x sxhkd; bspc wm -r";
+ "super + q" = "bspc node -c";
+ "super + m" = "bspc quit";
+
+ "super + a" = "rofi -show drun";
+ "super + period" = "rofi -show emoji -modi emoji";
+ "alt + F4" = "rofi -show power-menu -modi power-menu:rofi-power-menu";
+ "super + y" = "beesettings wall";
+ "super + comma" = "beesettings settings";
+ "super + b" = "zen";
+ "super + e" = "nautilus";
+ "super + F12" = "gnome-calculator";
+
+ "Print" = "${snip} full";
+ "super + Print" = "${snip} selection";
+
+ "super + {h,j,k,l}" = "bspc node -f {west,south,north,east}";
+ "super + shift + {h,j,k,l}" = "bspc node -s {west,south,north,east}";
+ "super + {Left,Down,Up,Right}" = "bspc node -v {-50 0,0 50,0 -50,50 0}";
+
+ "super + space" = "bspc node -t ~floating";
+ "alt + f" = "bspc node -t ~fullscreen";
+ "super + i" = "bspc node -g hidden=on";
+
+ "super + shift + i" = "bspc node any.hidden.local -g hidden=off";
+
+ "super + {1-9}" = "bspc desktop -f '^{1-9}'";
+ "super + shift + {1-9}" = "bspc node -d '^{1-9}'";
+
+ "XF86AudioRaiseVolume" = "volume-control up";
+ "XF86AudioLowerVolume" = "volume-control down";
+ "XF86AudioMute" = "volume-control mute";
+ "XF86AudioMicMute" = "mic-control toggle";
+ "XF86MonBrightnessUp" = "brightness-control up";
+ "XF86MonBrightnessDown" = "brightness-control down";
+
+ "XF86Audio{Play,Next,Prev,Stop}" = "playerctl {play-pause,next,previous,stop}";
+
+ "alt + h" = "bspc node -z left -50 0 || bspc node -z right -50 0";
+ "alt + j" = "bspc node -z bottom 0 50 || bspc node -z top 0 50";
+ "alt + k" = "bspc node -z top 0 -50 || bspc node -z bottom 0 -50";
+ "alt + l" = "bspc node -z right 50 0 || bspc node -z left 50 0";
+ "alt + a" = "bspc desktop -l next";
+ };
+ };
+ }
+ else
+ {
+ services.xserver = {
+ windowManager.bspwm.enable = true;
+ };
+ }
+ );
+}