{ pkgs, lib, config, userName, ... }: let cfg = config.home-manager.users.${userName}; in { monitor = [ ",preferred,auto,auto" "eDP-1,3840x2160@60,auto,1.5" ]; "$terminal" = "kitty"; "$menu" = "fuzzel"; exec-once = [ "wpaperd" ]; env = [ "NIXOS_OZONE_WL,1" "QT_QPA_PLATFORM,wayland" "QT_WAYLAND_DISABLE_WINDOWDECORATION,1" "GDK_BACKEND,wayland" "GDK_SCALE,0.66" "QT_AUTO_SCREEN_SCALE_FACTOR,1" "SDL_VIDEODRIVER,wayland" # "AQ_DRM_DEVICES,/dev/dri/by-path/pci-0000:01:00.0-card" "__NV_PRIME_RENDER_OFFLOAD,1" "__NV_PRIME_RENDER_OFFLOAD_PROVIDER,NVIDIA-G0" "__GLX_VENDOR_LIBRARY_NAME,nvidia" "__VK_LAYER_NV_optimus,NVIDIA_only" ]; xwayland.force_zero_scaling = true; general = { gaps_in = 3; gaps_out = 9; "col.active_border" = "rgba(33ccffee) rgba(00ff95ee) 45deg"; "col.inactive_border" = "rgba(595959aa)"; resize_on_border = false; allow_tearing = false; layout = "dwindle"; }; decoration = { rounding = 5; dim_special = 0.0; }; animations = { enabled = true; bezier = "myBezier, 0.05, 0.9, 0.1, 1.05"; animation = [ "windows, 1, 1, default, popin 80%" "windowsMove, 0" # "windows, 1, 7, myBezier" # "windowsOut, 1, 7, myBezier, popin 80%" "border, 1, 10, default" "borderangle, 1, 8, default" "fade, 1, 1, default" "workspaces, 1, 1, default, fade" # "workspaces, 1, 6, default" ]; }; dwindle = { pseudotile = false; preserve_split = true; }; master = { new_status = "master"; }; misc = { disable_hyprland_logo = true; disable_splash_rendering = true; # focus_on_activate = true; mouse_move_enables_dpms = true; key_press_enables_dpms = true; new_window_takes_over_fullscreen = 1; exit_window_retains_fullscreen = true; }; cursor = { hide_on_key_press = true; }; input = { kb_layout = "us,us"; kb_variant = "dvp,"; kb_model = ""; kb_options = "compose:caps,grp:win_space_toggle"; kb_rules = ""; follow_mouse = 1; sensitivity = 0; touchpad = { natural_scroll = false; }; }; device = [ { name = "synaptics-tm3512-010"; sensitivity = 0.4; } { name = "tpps/2-elan-trackpoint"; sensitivity = 0.2; } ]; gestures = { workspace_swipe = false; }; dwindle = { # no_gaps_when_only = 1; }; "$mainMod" = "SUPER"; bind = [ "$mainMod, return, exec, $terminal" "$mainMod, Q, killactive" "$mainMod, V, togglefloating" "$mainMod, D, exec, $menu" "$mainMod SHIFT, D, exec, $menu --list-executables-in-path" # "$mainMod, J, togglesplit," "$mainMod SHIFT, L, exec, loginctl lock-session" "$mainMod SHIFT, S, exec, systemctl suspend" "$mainMod SHIFT, E, exit" "$mainMod, left, movefocus, l" "$mainMod, right, movefocus, r" "$mainMod, up, movefocus, u" "$mainMod, down, movefocus, d" "$mainMod SHIFT, left, swapwindow, l" "$mainMod SHIFT, right, swapwindow, r" "$mainMod SHIFT, up, swapwindow, u" "$mainMod SHIFT, down, swapwindow, d" "$mainMod, T, cyclenext" "$mainMod, G, focusmonitor, 0" "$mainMod, C, focusmonitor, 1" "$mainMod, R, focusmonitor, 2" "$mainMod, L, focusmonitor, 3" "$mainMod CTRL, G, movecurrentworkspacetomonitor, 0" "$mainMod CTRL, C, movecurrentworkspacetomonitor, 1" "$mainMod CTRL, R, movecurrentworkspacetomonitor, 2" "$mainMod CTRL, L, movecurrentworkspacetomonitor, 3" "$mainMod, F, fullscreen, 1" "$mainMod SHIFT, F, fullscreen, 0" "$mainMod CTRL SHIFT, F, fullscreenstate, 1, 2" "$mainMod, code:14, workspace, 1" "$mainMod, code:17, workspace, 2" "$mainMod, code:13, workspace, 3" "$mainMod, code:18, workspace, 4" "$mainMod, code:12, workspace, 5" "$mainMod, code:19, workspace, 6" "$mainMod, code:11, workspace, 7" "$mainMod, code:20, workspace, 8" "$mainMod, code:15, workspace, 9" "$mainMod, code:16, workspace, 10" "$mainMod SHIFT, code:14, movetoworkspacesilent, 1" "$mainMod SHIFT, code:17, movetoworkspacesilent, 2" "$mainMod SHIFT, code:13, movetoworkspacesilent, 3" "$mainMod SHIFT, code:18, movetoworkspacesilent, 4" "$mainMod SHIFT, code:12, movetoworkspacesilent, 5" "$mainMod SHIFT, code:19, movetoworkspacesilent, 6" "$mainMod SHIFT, code:11, movetoworkspacesilent, 7" "$mainMod SHIFT, code:20, movetoworkspacesilent, 8" "$mainMod SHIFT, code:15, movetoworkspacesilent, 9" "$mainMod SHIFT, code:16, movetoworkspacesilent, 10" "CTRL, space, exec, dunstctl close" "CTRL SHIFT, space, exec, dunstctl close-all" "CTRL, period, exec, dunstctl context" "CTRL, comma, exec, dunstctl history-pop" "$mainMod ALT, E, exec, emacsclient -c" "$mainMod ALT, Y, exec, ${pkgs.writeShellScript "yt-dlp" '' export PATH="${lib.makeBinPath (with pkgs; [ wl-clipboard-rs socat ])}:$PATH" socat STDIO UNIX-CONNECT:"$XDG_RUNTIME_DIR"/yt-dlp.sock <<<$'{ "urls": ["'"$(wl-paste)"$'"] }' ''}" ", XF86MonBrightnessUp, exec, lightctl -d -e4 -n1 up" ", XF86MonBrightnessDown, exec, lightctl -d -e4 -n1 down" ", XF86AudioRaiseVolume, exec, volumectl -d -u up" ", XF86AudioLowerVolume, exec, volumectl -d -u down" ", XF86AudioMute, exec, volumectl -d toggle-mute" ", XF86AudioMicMute, exec, volumectl -d -m toggle-mute" ", Print, exec, ${pkgs.writeShellScript "screenshot" '' export PATH="${lib.makeBinPath (with pkgs; [ grim slurp wl-clipboard-rs coreutils ])}:$PATH" outFile="$HOME/screenshots/$(date +"%Y-%m-%dT%H:%M:%S").png" grim -g "$(slurp -b 00000080 -c FFFFFFFF -s 00000000 -w 1)" "$outFile" wl-copy --type image/png <"$outFile" ''}" "SHIFT, Print, exec, ${pkgs.writeShellScript "screenshot" '' export PATH="${lib.makeBinPath (with pkgs; [ grim jq wl-clipboard-rs coreutils ])}:$PATH" outFile="$HOME/screenshots/$(date +"%Y-%m-%dT%H:%M:%S").png" grim -o "$(hyprctl monitors -j | jq -r '.[] | select(.focused) | .name')" "$outFile" wl-copy --type image/png <"$outFile" ''}" "CTRL SHIFT, Print, exec, ${pkgs.runCommand "picker" { buildInputs = [ pkgs.makeWrapper ]; } '' makeWrapper ${lib.getExe pkgs.hyprpicker} $out \ --prefix PATH : ${lib.makeBinPath [pkgs.wl-clipboard-rs]} ''} -a" "$mainMod, M, exec, ${pkgs.writeShellScript "qalc-fuzzel" '' export PATH="${lib.makeBinPath (with pkgs; [ wl-clipboard-rs libqalculate cfg.programs.fuzzel.package coreutils findutils libnotify gnugrep ])}:$PATH" RESULTS_DIR="$HOME/.cache/qalc-fuzzel" prev() { FOUND=false while IFS= read -r line; do [[ -n "$line" ]] || continue FOUND=true echo $line done < <(export LC_ALL=C.UTF-8; echo; find "$RESULTS_DIR" -type f -printf $'%T@ %p\n' | sort -n | cut -d' ' -f2- | xargs -r cat) $FOUND || echo } FUZZEL_RES=$(prev | fuzzel --dmenu --prompt "qalc> ") || exit $? if [[ "$FUZZEL_RES" =~ .*\ =\ .* ]]; then QALC_RES="$FUZZEL_RES" QALC_RET=0 else QALC_RES=$(qalc "$FUZZEL_RES" 2>&1) QALC_RET=$? fi [[ -n "$QALC_RES" ]] || exit 1 EXISTING=false fgrep -xrl "$QALC_RES" "$RESULTS_DIR" | xargs -r touch [[ ''${PIPESTATUS[0]} -eq 0 ]] && EXISTING=true if [[ $QALC_RET -eq 0 ]] && ! $EXISTING; then RES_FILE="$RESULTS_DIR"/$(date -uIs).$(tr -Cd 'a-zA-Z0-9' "$RES_FILE" <<<"$QALC_RES" fi [[ "$QALC_RES" =~ .*\ =\ (.*) ]] && QALC_RES="''${BASH_REMATCH[1]}" [[ $QALC_RET -eq 0 ]] && wl-copy "$QALC_RES" notify-send "$QALC_RES" ''}" "$mainMod, E, exec, ${pkgs.writeShellScript "emoji-fuzzel" '' export PATH="${lib.makeBinPath (with pkgs; [ cfg.programs.fuzzel.package wtype wl-clipboard-rs ])}:$PATH" FUZZEL_RES=$(fuzzel --dmenu --prompt "emoji> " <$HOME/.local/share/emoji-data/list.txt) || exit $? [[ -n "$FUZZEL_RES" ]] || exit 1 wl-copy "$(cut -d ':' -f 1 <<<"$FUZZEL_RES" | tr -d '\n')" && wtype -k XF86Paste ''}" "$mainMod, B, exec, ${pkgs.writeShellScript "bring" '' export PATH="${lib.makeBinPath (with pkgs; [ cfg.programs.fuzzel.package gawk gojq cfg.wayland.windowManager.hyprland.package ])}:$PATH" state="$(hyprctl -j clients)" active_window="$(hyprctl -j activewindow)" active_workspace="$(hyprctl -j activeworkspace | gojq -r '.id')" current_addr="$(echo "$active_window" | gojq -r '.address')" window="$(echo "$state" | gojq -r '.[] | select(.workspace.id == '"$active_workspace"') | select(.monitor != -1 ) | "\(.title)\t\(.address)"' | fuzzel --log-level=warning --dmenu)" addr="$(echo "$window" | awk -F $'\t' '{print $2}')" if [[ "$addr" = "$current_addr" ]]; then exit 0 fi fullscreen_on_same_ws="$(echo "$state" | gojq -r '.[] | select(.fullscreen == true) | select(.workspace.id == '"$active_workspace"') | .address')" if [[ "$window" != "" ]]; then if [[ "$fullscreen_on_same_ws" == "" ]]; then hyprctl dispatch focuswindow address:"''${addr}" else # If we want to focus app_A and app_B is fullscreen on the same workspace, # app_A will get focus, but app_B will remain on top. # This monstrosity is to make sure app_A will end up on top instead. # XXX: doesn't handle fullscreen 0, but I don't care. hyprctl --batch "dispatch focuswindow address:''${fullscreen_on_same_ws}; dispatch fullscreen 1; dispatch focuswindow address:''${addr}; dispatch fullscreen 1" fi fi ''}" "$mainMod SHIFT, B, exec, ${pkgs.writeShellScript "bring" '' export PATH="${lib.makeBinPath (with pkgs; [ cfg.programs.fuzzel.package gawk gojq cfg.wayland.windowManager.hyprland.package ])}:$PATH" state="$(hyprctl -j clients)" active_window="$(hyprctl -j activewindow)" current_addr="$(echo "$active_window" | gojq -r '.address')" window="$(echo "$state" | gojq -r '.[] | select(.monitor != -1 ) | "\(.title)\t\(.workspace.name)\t\(.address)"' | fuzzel --log-level=warning --dmenu)" addr="$(echo "$window" | awk -F $'\t' '{print $3}')" ws="$(echo "$window" | awk -F $'\t' '{print $2}')" if [[ "$addr" = "$current_addr" ]]; then exit 0 fi fullscreen_on_same_ws="$(echo "$state" | gojq -r ".[] | select(.fullscreen == true) | select(.workspace.name == \"$ws\") | .address")" if [[ "$window" != "" ]]; then if [[ "$fullscreen_on_same_ws" == "" ]]; then hyprctl dispatch focuswindow address:"''${addr}" else # If we want to focus app_A and app_B is fullscreen on the same workspace, # app_A will get focus, but app_B will remain on top. # This monstrosity is to make sure app_A will end up on top instead. # XXX: doesn't handle fullscreen 0, but I don't care. hyprctl --batch "dispatch focuswindow address:''${fullscreen_on_same_ws}; dispatch fullscreen 1; dispatch focuswindow address:''${addr}; dispatch fullscreen 1" fi fi ''}" "$mainMod CTRL, return, togglespecialworkspace, term" "$mainMod CTRL, e, togglespecialworkspace, edit" "$mainMod CTRL, a, togglespecialworkspace, pwvucontrol" "$mainMod CTRL, o, togglespecialworkspace, easyeffects" "$mainMod CTRL, b, togglespecialworkspace, blueman" "$mainMod CTRL, p, togglespecialworkspace, keepass" ]; bindm = [ "$mainMod, mouse:272, movewindow" "$mainMod, mouse:273, resizewindow" ]; bindl = [ ", switch:off:Lid Switch,exec,hyprctl dispatch dpms on eDP-1" ", switch:on:Lid Switch,exec,hyprctl dispatch dpms off eDP-1" ", switch:off:Lid Switch,exec,${pkgs.writeShellScript "clamshell-off" '' export PATH="${lib.makeBinPath (with pkgs; [ jq ])}:$PATH" [[ $(hyprctl monitors -j | jq '.[] | select(.name == "eDP-1") | .disabled') = "true" ]] || exit 0 hyprctl keyword monitor "eDP-1,3840x2160@60,auto,1.5" ''}" ", switch:on:Lid Switch,exec,${pkgs.writeShellScript "clamshell-on" '' export PATH="${lib.makeBinPath (with pkgs; [ jq ])}:$PATH" [[ $(hyprctl monitors -j | jq 'reduce (.[] | select(.disabled == false)) as $_ (0; .+1)') -gt 1 ]] || exit 0 hyprctl keyword monitor "eDP-1,disable" ''}" ]; windowrulev2 = [ "suppressevent maximize fullscreen, class:.*" # "maximize, class:^(Element|thunderbird)$" "workspace special:pwvucontrol, class:^com\.saivert\.pwvucontrol$" "workspace special:easyeffects, class:^com\.github\.wwmm\.easyeffects$" "workspace special:blueman, class:^\.blueman-manager-wrapped$" "workspace special:keepass silent, class:^org\.keepassxc\.KeePassXC$, title:^(?!Unlock Database.*)(?!.*(Access Request|Passkey credentials))" # "group set always lock invade, class:^Element$" "workspace 2, class:^firefox$" "workspace 4, class:^evince$" "workspace 4, class:^imv$" "workspace 4, class:^org\.pwmt\.zathura$" "workspace 10, class:^mpv$" "workspace 1, class:^Element$" "workspace 1, class:^thunderbird$" "workspace 5, class:^virt-manager$" "workspace 5, class:^qemu$" "float, class:^org\.keepassxc\.KeePassXC$, title:Access Request$" "center, class:^org\.keepassxc\.KeePassXC$, title:Access Request$" "float, class:^org\.keepassxc\.KeePassXC$, title:Passkey credentials$" "center, class:^org\.keepassxc\.KeePassXC$, title:Passkey credentials$" "float, class:^org\.keepassxc\.KeePassXC$, title:^Unlock Database" "center, class:^org\.keepassxc\.KeePassXC$, title:^Unlock Database" "float, class:^xdg-desktop-portal-gtk$" "center, class:^xdg-desktop-portal-gtk$" "bordercolor rgba(ffaa33ee) rgba(bfff00ee) 45deg, fullscreen:1" "bordercolor rgba(3366ffee) rgba(6a00ffee) 45deg, xwayland:1" "bordercolor rgba(6633ffee) rgba(ea00ffee) 45deg, xwayland:1, fullscreen:1" ]; workspace = [ "s[true], gapsout:100" "special:term, on-created-empty:kitty" "special:edit, on-created-empty:emacsclient -c" "special:pwvucontrol, on-created-empty:pwvucontrol" "special:easyeffects, on-created-empty:easyeffects" "special:blueman, on-created-empty:blueman-manager" "special:keepass, on-created-empty:keepassxc" "1, defaultName:comm" "2, defaultName:web" "3, defaultName:work" "4, defaultName:read" ]; layerrule = [ "blur, waybar" "blur, launcher" "noanim, notifications" "blur, notifications" ]; }