nix-infra/common/fragments/graphical/bspwm.nix

129 lines
4.9 KiB
Nix
Raw Normal View History

2023-04-20 20:22:22 +00:00
{ lib, pkgs, config, ... }: {
2023-03-26 16:33:03 +00:00
home-manager.users.agatha = {
xsession.windowManager.bspwm = {
enable = true;
extraConfigEarly = lib.strings.concatStringsSep "\n" [
"xsetroot -cursor_name left_ptr"
2023-06-01 17:07:54 +00:00
"xinput set-prop 'SynPS/2 Synaptics TouchPad' 'libinput Scrolling Pixel Distance' 10"
2023-04-07 16:21:43 +00:00
"setxkbmap"
2023-03-26 16:33:03 +00:00
];
extraConfig = let
2023-09-17 16:57:46 +00:00
startOnce =
map (v: "! pgrep ${builtins.head (lib.splitString " " v)} && ${v} &");
startup = startOnce [
"firefox"
"element-desktop"
"telegram-desktop"
"spotify"
"geary"
2023-06-20 15:19:03 +00:00
"bspm -d"
];
2023-09-17 16:57:46 +00:00
monitors = builtins.genList (_: _) (builtins.length (builtins.attrValues
config.home-manager.users.agatha.xsession.windowManager.bspwm.monitors));
nitrogen = map (i:
"nitrogen --head=${toString i} --set-zoom-fill ${
config.environment.graphical.colorschemes."${config.environment.graphical.theme.name}".image
}") monitors;
in lib.strings.concatStringsSep "\n" (nitrogen ++ startup);
2023-04-20 20:22:22 +00:00
settings = let
color = n:
config.environment.graphical.colors."${config.environment.graphical.theme.name}"."${builtins.toString
n}";
2023-03-26 16:33:03 +00:00
in {
border_width = 3;
window_gap = 15;
top_padding = 45;
split_ratio = 0.5;
borderless_monocle = false;
gapless_monocle = false;
normal_border_color = color 0;
focused_border_color = color 1;
active_border_color = color 2;
urgent_border_color = color 2;
presel_feedback_color = color 2;
};
rules = {
"Gimp" = {
state = "tiled";
follow = true;
};
"Yubico Authenticator".state = "floating";
};
};
services.sxhkd = {
enable = true;
keybindings = {
# Disable middle click paste
"~button2" = "echo -n | xclip -in";
2023-03-26 16:33:03 +00:00
# Terminal
"super + Return" = "kitty";
"Caps_Lock" = "kitty";
# File explorer
"super + e" = "nautilus";
# Program launcher
"super + @space" = "rofi -show drun";
# Clipboard
"super + v" = "clipcat-menu";
2023-03-26 16:33:03 +00:00
# Calculator
"super + shift + c" = ''
2023-03-27 15:21:43 +00:00
ROFI_PLUGIN_PATH=${pkgs.rofi-calc}/lib/rofi rofi -show calc -modi calc -calc-command '${pkgs.xdotool}/bin/xdotool type --clearmodifiers "\{result\}'
'';
2023-04-07 16:21:43 +00:00
"super + shift + e" = ''
rofimoji --action clipboard
'';
2023-03-26 16:33:03 +00:00
# Media keys
"XF86Audio{Raise,Lower}Volume" = "pamixer {-i,-d} 5";
"XF86AudioMute" = "pamixer -t";
"XF86Audio{Prev,Next}" = "playerctl {previous,next}";
"XF86AudioPlay" = "playerctl play-pause";
2023-07-07 14:09:23 +00:00
"XF86MonBrightness{Up,Down}" = ''
brightnessctl set 10%{+,-} && dunstify -r 98114 -h int:value:$(( $(brightnessctl get) * 100 / $(brightnessctl max) )) "Brightness set to:"
'';
2023-06-19 18:25:08 +00:00
# Switch outputs
"super + o" = ''
dunstify -r 112119 "Sound output switched to $(${pkgs.pads}/bin/pads next && ${pkgs.pads}/bin/pads list | rg '^\*' | choose 1:)"'';
2023-03-26 16:33:03 +00:00
# Screenshot
"Print" = "flameshot gui && bspc desktop --focus focused";
"shift + Print" =
"flameshot gui -d 3000 && bspc desktop --focus focused";
# Pause notifications
"super + n" = "dunstctl set-paused toggle";
# Reload WM
"super + shift + {q,r}" = ''
pkill -USR1 -x sxhkd \
; for p in picom polybar dunst; killall $p; end \
; bspc {quit,wm -r}
'';
# Close/kill window
"super + {_,shift + }w" = "bspc node -{c,k}";
# Monocle layout
2023-06-20 15:19:03 +00:00
"super + m" = "bspm monocle --toggle";
"super + shift + m" = "bspm monocle --next";
2023-03-26 16:33:03 +00:00
# Toggle hide all windows
"super + d" =
"bspc query -N -n .window | xargs -I node_id bspc node node_id -g hidden";
# Change window state
"super + {t,shift + t,s,f}" =
"bspc node -t {tiled,pseudo_tiled,floating,fullscreen}";
# Focus/move window
"super + {_,shift + }{j,k,i,l}" =
"bspc node -{f,s} {west,south,north,east}";
# Focus the next window in the current desktop
"super + c" = "bspc node -f next.local.!hidden.window";
# Focus previous/next desktop on current monitor
"super + bracket{left,right}" = "bspc desktop -f {prev,next}.local";
# Switch desktops / Move window to desktop
"super + {_,shift + }{1-9,0}" = "bspc {desktop -f,node -d} '^{1-9,10}'";
# Window switcher
"alt + Tab" = "rofi -show window";
# Move floating window
"super + {Left,Down,Up,Right}" = "bspc node -v {-20 0,0 20,0 -20,20 0}";
# Lock screen
2023-04-07 16:21:43 +00:00
"super + x" = ''
betterlockscreen --lock dimblur --time-format "%H:%M"; systemctl --user restart gpg-agent'';
2023-03-26 16:33:03 +00:00
};
};
};
}