input {
  keyboard {
  xkb {
  }
  numlock
  }
  touchpad {
    tap
    natural-scroll
  }
  mouse {
      accel-speed 1.0
  }
  trackpoint {
 }
}
cursor {
  xcursor-theme "Bibata-Modern-Classic"
  xcursor-size 24
}
gestures {
  hot-corners {
    off
  }
}
layout {
  gaps 16
  background-color "transparent"
  center-focused-column "never"
  always-center-single-column
  preset-column-widths {
    proportion 0.33333
    proportion 0.5
    proportion 0.66667
  }
  default-column-width { proportion 0.5; }
  focus-ring {
    //off
    width 3
    active-color "#7fc8ff"
    inactive-color "#505050"
  }
  border {
    off
    width 4
    active-color "#ffc87f"
    inactive-color "#505050"
    urgent-color "#9b0000"
  }
  shadow {
    //on
    //draw-behind-window true
    softness 30
    spread 5
    offset x=0 y=5
    color "#0007"
  }
  struts {
  }
}
hotkey-overlay {
    skip-at-startup
}
prefer-no-csd
screenshot-path "~/Pictures/Screenshots/Screenshot from %Y-%m-%d %H-%M-%S.png"
//animations {
    // off
    // slowdown 3.0
//}
animations {
    window-close {
        duration-ms 600
        curve "ease-out-quad"

        custom-shader r"
            float hash21(vec2 p) {
                return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
            }

            float value_noise(vec2 p) {
                vec2 i = floor(p);
                vec2 f = fract(p);
                vec2 u = f * f * (3.0 - 2.0 * f);
                return mix(
                    mix(hash21(i), hash21(i + vec2(1.0, 0.0)), u.x),
                    mix(hash21(i + vec2(0.0, 1.0)), hash21(i + vec2(1.0, 1.0)), u.x),
                    u.y
                );
            }

            float fbm(vec2 p) {
                float v = 0.0;
                float amp = 0.5;
                float freq = 1.0;
                for (int i = 0; i < 5; i++) {
                    v += amp * value_noise(p * freq);
                    freq *= 2.0;
                    amp *= 0.5;
                }
                return v;
            }

            vec4 close_color(vec3 coords_geo, vec3 size_geo) {
                vec2 uv = coords_geo.xy;
                float p = niri_clamped_progress;
                float seed = niri_random_seed * 100.0;

                // Distance from nearest edge of window rect
                float dx = min(uv.x, 1.0 - uv.x);
                float dy = min(uv.y, 1.0 - uv.y);
                float edge_dist = min(dx, dy);

                // Noise-driven edge erosion: breaks the box shape
                float edge_noise = fbm((uv + seed) * 8.0 * 1.5);
                float erode = p * 0.80;
                float edge_threshold = edge_noise * erode;
                float edge_alpha = smoothstep(edge_threshold - 0.02, edge_threshold + 0.02, edge_dist);

                // Skip pixels far outside eroded boundary
                if (edge_dist < -0.15) {
                    return vec4(0.0);
                }

                // Wobble the window content
                vec2 np = (uv + seed) * 8.0;
                float wx = fbm(np + vec2(17.3, 0.0)) - 0.5;
                float wy = fbm(np + vec2(0.0, 43.1)) - 0.5;

                vec3 warped = coords_geo;
                warped.x += wx * 0.080 * p;
                warped.y += wy * 0.080 * p;

                vec3 tex_coords = niri_geo_to_tex * warped;
                vec4 color = texture2D(niri_tex, tex_coords.st);

                // Overall fade
                float alpha = edge_alpha * (1.0 - p * p);
                alpha = clamp(alpha, 0.0, 1.0);

                // Warm glow at dissolving edges
                float glow = smoothstep(edge_threshold - 0.04, edge_threshold, edge_dist)
                           * (1.0 - smoothstep(edge_threshold, edge_threshold + 0.04, edge_dist));
                glow *= (1.0 - p) * 0.6;
                color.rgb += vec3(0.3, 0.18, 0.06) * glow;

                return color * alpha;
            }
        "
    }
    window-open {
        duration-ms 600
        curve "ease-out-expo"

        custom-shader r"
            float hash21(vec2 p) {
                return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
            }

            float value_noise(vec2 p) {
                vec2 i = floor(p);
                vec2 f = fract(p);
                vec2 u = f * f * (3.0 - 2.0 * f);
                return mix(
                    mix(hash21(i), hash21(i + vec2(1.0, 0.0)), u.x),
                    mix(hash21(i + vec2(0.0, 1.0)), hash21(i + vec2(1.0, 1.0)), u.x),
                    u.y
                );
            }

            float fbm(vec2 p) {
                float v = 0.0;
                float amp = 0.5;
                float freq = 1.0;
                for (int i = 0; i < 5; i++) {
                    v += amp * value_noise(p * freq);
                    freq *= 2.0;
                    amp *= 0.5;
                }
                return v;
            }

            vec4 open_color(vec3 coords_geo, vec3 size_geo) {
                vec2 uv = coords_geo.xy;
                float p = 1.0 - niri_clamped_progress;
                float seed = niri_random_seed * 100.0;

                // Distance from nearest edge of window rect
                float dx = min(uv.x, 1.0 - uv.x);
                float dy = min(uv.y, 1.0 - uv.y);
                float edge_dist = min(dx, dy);

                // Noise-driven edge erosion: breaks the box shape
                float edge_noise = fbm((uv + seed) * 8.0 * 1.5);
                float erode = p * 0.80;
                float edge_threshold = edge_noise * erode;
                float edge_alpha = smoothstep(edge_threshold - 0.02, edge_threshold + 0.02, edge_dist);

                // Skip pixels far outside eroded boundary
                if (edge_dist < -0.15) {
                    return vec4(0.0);
                }

                // Wobble the window content
                vec2 np = (uv + seed) * 8.0;
                float wx = fbm(np + vec2(17.3, 0.0)) - 0.5;
                float wy = fbm(np + vec2(0.0, 43.1)) - 0.5;

                vec3 warped = coords_geo;
                warped.x += wx * 0.080 * p;
                warped.y += wy * 0.080 * p;

                vec3 tex_coords = niri_geo_to_tex * warped;
                vec4 color = texture2D(niri_tex, tex_coords.st);

                // Overall fade
                float alpha = edge_alpha * (1.0 - p * p);
                alpha = clamp(alpha, 0.0, 1.0);

                // Warm glow at dissolving edges
                float glow = smoothstep(edge_threshold - 0.04, edge_threshold, edge_dist)
                           * (1.0 - smoothstep(edge_threshold, edge_threshold + 0.04, edge_dist));
                glow *= (1.0 - p) * 0.6;
                color.rgb += vec3(0.3, 0.18, 0.06) * glow;

                return color * alpha;
            }
        "
    }
}
window-rule {
    geometry-corner-radius 8
    clip-to-geometry true
}
window-rule {
  match app-id=r#"org.quickshell$"#
  open-floating true
}
window-rule {
  match app-id="org.gnome.Calculator"
  open-floating true
}
window-rule {
  match app-id="mpv"
  open-floating true
  default-floating-position x=0 y=32 relative-to="bottom"
}
window-rule {
  match app-id="^ghostty$"
  opacity 0.8
  background-effect {
      blur true
  }
}
window-rule {
 draw-border-with-background false
}
// spawn-sh-at-startup "qs -c ~/source/qs/MyAwesomeShell"
// spawn-at-startup "waybar"
binds {
    Mod+Shift+Slash { show-hotkey-overlay; }
    Mod+Alt+P hotkey-overlay-title="Open Power Menu" { spawn "dms" "ipc" "call" "powermenu" "toggle"; }
    Mod+Alt+I hotkey-overlay-title="Toggle Idle Inhibitoer" { spawn "dms" "ipc" "call" "inhibit" "toggle"; }
    Mod+Q hotkey-overlay-title="Open a Terminal: ghostty" { spawn "ghostty"; }
    Mod+Space hotkey-overlay-title="Run an Application: dank launcher" { spawn "dms" "ipc" "call" "launcher" "toggle"; }
    //Mod+Space hotkey-overlay-title="Run an Application: fuzzel" { spawn "fuzzel"; }
    Mod+W hotkey-overlay-title="Open a Web browser: firefox" { spawn "firefox"; }
    Mod+E hotkey-overlay-title="Open File browser: nautilus" { spawn "nautilus"; }
    XF86AudioRaiseVolume allow-when-locked=true { spawn-sh "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1+ -l 1.0"; }
    Mod+Alt+WheelScrollUp { spawn "dms" "ipc" "call" "audio" "increment" "5"; }
    Mod+Alt+WheelScrollDown { spawn "dms" "ipc" "call" "audio" "decrement" "5"; }
    XF86AudioLowerVolume allow-when-locked=true { spawn-sh "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1-"; }
    XF86AudioMute        allow-when-locked=true { spawn-sh "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"; }
    XF86AudioMicMute     allow-when-locked=true { spawn-sh "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"; }
    XF86AudioPlay        allow-when-locked=true { spawn-sh "playerctl play-pause"; }
    XF86AudioStop        allow-when-locked=true { spawn-sh "playerctl stop"; }
    XF86AudioPrev        allow-when-locked=true { spawn-sh "playerctl previous"; }
    XF86AudioNext        allow-when-locked=true { spawn-sh "playerctl next"; }
    XF86MonBrightnessUp allow-when-locked=true { spawn "brightnessctl" "--class=backlight" "set" "+10%"; }
    XF86MonBrightnessDown allow-when-locked=true { spawn "brightnessctl" "--class=backlight" "set" "10%-"; }
    Mod+O repeat=false { toggle-overview; }
    Mod+Escape repeat=false { close-window; }
    Mod+Left  { focus-column-left; }
    Mod+Down  { focus-window-down; }
    Mod+Up    { focus-window-up; }
    Mod+Right { focus-column-right; }
    Mod+H     { focus-column-left; }
    Mod+J     { focus-window-down; }
    Mod+K     { focus-window-up; }
    Mod+L     { focus-column-right; }
    Mod+Ctrl+Left  { move-column-left; }
    Mod+Ctrl+Down  { move-window-down; }
    Mod+Ctrl+Up    { move-window-up; }
    Mod+Ctrl+Right { move-column-right; }
    Mod+Ctrl+H     { move-column-left; }
    Mod+Ctrl+J     { move-window-down; }
    Mod+Ctrl+K     { move-window-up; }
    Mod+Ctrl+L     { move-column-right; }
    Mod+Home { focus-column-first; }
    Mod+End  { focus-column-last; }
    Mod+Ctrl+Home { move-column-to-first; }
    Mod+Ctrl+End  { move-column-to-last; }
    Mod+Shift+Left  { focus-monitor-left; }
    Mod+Shift+Down  { focus-monitor-down; }
    Mod+Shift+Up    { focus-monitor-up; }
    Mod+Shift+Right { focus-monitor-right; }
    Mod+Shift+H     { focus-monitor-left; }
    Mod+Shift+J     { focus-monitor-down; }
    Mod+Shift+K     { focus-monitor-up; }
    Mod+Shift+L     { focus-monitor-right; }
    Mod+Shift+Ctrl+Left  { move-column-to-monitor-left; }
    Mod+Shift+Ctrl+Down  { move-column-to-monitor-down; }
    Mod+Shift+Ctrl+Up    { move-column-to-monitor-up; }
    Mod+Shift+Ctrl+Right { move-column-to-monitor-right; }
    Mod+Shift+Ctrl+H     { move-column-to-monitor-left; }
    Mod+Shift+Ctrl+J     { move-column-to-monitor-down; }
    Mod+Shift+Ctrl+K     { move-column-to-monitor-up; }
    Mod+Shift+Ctrl+L     { move-column-to-monitor-right; }
    Mod+Page_Down      { focus-workspace-down; }
    Mod+Page_Up        { focus-workspace-up; }
    Mod+U              { focus-workspace-down; }
    Mod+I              { focus-workspace-up; }
    Mod+Ctrl+Page_Down { move-column-to-workspace-down; }
    Mod+Ctrl+Page_Up   { move-column-to-workspace-up; }
    Mod+Ctrl+U         { move-column-to-workspace-down; }
    Mod+Ctrl+I         { move-column-to-workspace-up; }
    Mod+Shift+Page_Down { move-workspace-down; }
    Mod+Shift+Page_Up   { move-workspace-up; }
    Mod+Shift+U         { move-workspace-down; }
    Mod+Shift+I         { move-workspace-up; }
    Mod+WheelScrollDown      cooldown-ms=150 { focus-workspace-down; }
    Mod+WheelScrollUp        cooldown-ms=150 { focus-workspace-up; }
    Mod+Ctrl+WheelScrollDown cooldown-ms=150 { move-column-to-workspace-down; }
    Mod+Ctrl+WheelScrollUp   cooldown-ms=150 { move-column-to-workspace-up; }
    Mod+WheelScrollRight      { focus-column-right; }
    Mod+WheelScrollLeft       { focus-column-left; }
    Mod+Ctrl+WheelScrollRight { move-column-right; }
    Mod+Ctrl+WheelScrollLeft  { move-column-left; }
    Mod+Shift+WheelScrollDown      { focus-column-right; }
    Mod+Shift+WheelScrollUp        { focus-column-left; }
    Mod+Ctrl+Shift+WheelScrollDown { move-column-right; }
    Mod+Ctrl+Shift+WheelScrollUp   { move-column-left; }
    Mod+1 { focus-workspace 1; }
    Mod+2 { focus-workspace 2; }
    Mod+3 { focus-workspace 3; }
    Mod+4 { focus-workspace 4; }
    Mod+5 { focus-workspace 5; }
    Mod+6 { focus-workspace 6; }
    Mod+7 { focus-workspace 7; }
    Mod+8 { focus-workspace 8; }
    Mod+9 { focus-workspace 9; }
    Mod+Ctrl+1 { move-column-to-workspace 1; }
    Mod+Ctrl+2 { move-column-to-workspace 2; }
    Mod+Ctrl+3 { move-column-to-workspace 3; }
    Mod+Ctrl+4 { move-column-to-workspace 4; }
    Mod+Ctrl+5 { move-column-to-workspace 5; }
    Mod+Ctrl+6 { move-column-to-workspace 6; }
    Mod+Ctrl+7 { move-column-to-workspace 7; }
    Mod+Ctrl+8 { move-column-to-workspace 8; }
    Mod+Ctrl+9 { move-column-to-workspace 9; }
    Mod+BracketLeft  { consume-or-expel-window-left; }
    Mod+BracketRight { consume-or-expel-window-right; }
    Mod+Comma  { consume-window-into-column; }
    Mod+Period { expel-window-from-column; }
    Mod+R { switch-preset-column-width; }
    Mod+Shift+R { switch-preset-window-height; }
    Mod+Ctrl+R { reset-window-height; }
    Mod+F { maximize-column; }
    Mod+Shift+F { fullscreen-window; }
    Mod+Ctrl+F { expand-column-to-available-width; }
    Mod+C { center-column; }
    Mod+Ctrl+C { center-visible-columns; }
    Mod+Minus { set-column-width "-10%"; }
    Mod+Equal { set-column-width "+10%"; }
    Mod+Shift+Minus { set-window-height "-10%"; }
    Mod+Shift+Equal { set-window-height "+10%"; }
    //Mod+V       { toggle-window-floating; }
    Mod+Shift+V { switch-focus-between-floating-and-tiling; }
    Mod+Shift+W { toggle-column-tabbed-display; }
    Shift+Alt+R { screenshot; }
    Shift+Alt+S { screenshot-screen; }
    Shift+Alt+W { screenshot-window; }
    Mod+Shift+Escape allow-inhibiting=false { toggle-keyboard-shortcuts-inhibit; }
    Mod+Shift+E { quit; }
    Ctrl+Alt+Delete { quit; }
    Mod+Shift+P { power-off-monitors; }
}
include "dms/binds.kdl"

include "dms/outputs.kdl"

include "dms/windowrules.kdl"

include "dms/cursor.kdl"
