# See https://wiki.hyprland.org/Configuring/Monitors/

# Wayland related environment variables.
env = HYPRCURSOR_THEME,McMojave
env = HYPRCURSOR_SIZE,30
env = TERMINAL,st
env = QT_QPA_PLATFORM,wayland

opengl {
    nvidia_anti_flicker = false
}

cursor {
    no_hardware_cursors = true
}

# For all categories, see https://wiki.hyprland.org/Configuring/Variables/
input {
    kb_layout = us
    kb_variant =
    kb_model =
    kb_options =
    kb_rules =

    # Mouse settings
    follow_mouse = 1
    accel_profile = adaptive # Or else cannot move camera in games
    sensitivity = 1
    focus_on_close = 1

    touchpad {
        natural_scroll = yes
    }

    repeat_delay = 300
    repeat_rate = 50

    sensitivity = 0 # -1.0 - 1.0, 0 means no modification.

    # kb_options = caps:swapescape
}

general {
    # See https://wiki.hyprland.org/Configuring/Variables/ for more

    gaps_in = 6
    gaps_out = 12
    border_size = 2
    # col.active_border = rgba(33ccffee) rgba(00ff99ee) 45deg
    col.active_border = rgba(83a598ff) rgba(acc3baff) 45deg
    # col.active_border = rgba(fc8577ff) rgba(fb4934ff) 45deg
    # col.active_border = rgba(b3d5a7ff) rgba(8ec07cff) 45deg
    col.inactive_border = rgba(595959aa)

    layout = master

    # Please see https://wiki.hyprland.org/Configuring/Tearing/ before you turn this on
    allow_tearing = false
}

blurls = waybar
decoration {
    # See https://wiki.hyprland.org/Configuring/Variables/ for more

    rounding = 10
    
    blur {
        enabled = true
        size = 3
        passes = 2
    }

    # drop_shadow = no
    # shadow_range = 4
    # shadow_render_power = 3
    # col.shadow = rgba(1a1a1aee)
}

animations {
    enabled = yes

    # Some default animations, see https://wiki.hyprland.org/Configuring/Animations/ for more

    bezier = myBezier, 0.05, 0.9, 0.1, 1.05
    bezier = linear, 0.0, 0.0, 1.0, 1.0

    animation = windows, 1, 7, myBezier
    animation = windowsOut, 1, 7, default, popin 80%
    animation = border, 1, 10, default
    animation = borderangle, 1, 100, linear, loop
    animation = fade, 1, 7, default
    animation = workspaces, 1, 6, default
}

dwindle {
    # See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more
    pseudotile = yes # master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below
    preserve_split = yes # you probably want this
}

master {
    # See https://wiki.hyprland.org/Configuring/Master-Layout/ for more
    new_on_top = true
    new_status = master
    orientation = left
}

# Replicate old "smart gaps"/"no gaps when only" option
workspace = w[tv1], gapsout:0, gapsin:0
workspace = f[1], gapsout:0, gapsin:0
windowrulev2 = bordersize 0, floating:0, onworkspace:w[tv1]
windowrulev2 = rounding 0, floating:0, onworkspace:w[tv1]
windowrulev2 = bordersize 0, floating:0, onworkspace:f[1]
windowrulev2 = rounding 0, floating:0, onworkspace:f[1]
windowrulev2 = float, class:nm-tray

gestures {
    # See https://wiki.hyprland.org/Configuring/Variables/ for more
    workspace_swipe = off
}

misc {
    # See https://wiki.hyprland.org/Configuring/Variables/ for more
    force_default_wallpaper = 0 # Set to 0 to disable the anime mascot wallpapers
    # enable_swallow = true
    # swallow_regex = ^(st-256color)$
    mouse_move_enables_dpms = true
}

# Window rules
windowrule = tile,title:^(VRChat)$
windowrule = tile,title:^(nsxiv)$

# windowrulev2 = suppressevent maximize, class:.* # Some windows try to maximize themselves instantly
# windowrulev2 = suppressevent fullscreen, class:.*
windowrulev2 = pin,title:^(dragon)$

# When hiding waybar, fixes the blur layer still being present
layerrule = ignorezero, waybar

$mainMod = SUPER

# Program spawning hotkeys
bind = CONTROL ALT, BACKSPACE, exec, st -e zsh -c 'btop'
bind = $mainMod CONTROL, W,    exec, [floating] foot -W 78x38 -e nmtui
bind = $mainMod,       RETURN, exec, st
bind = $mainMod,       W,      exec, zen
bind = $mainMod,       E,      exec, st -e zsh -c 'tmp="$(mktemp -t "yazi-cwd.XXXXX")"; yazi "$@" --cwd-file="$tmp"; printf "\033]0;st\007"; if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then; cd -- "$cwd"; fi; rm -f -- "$tmp"; exec $SHELL'
bind = $mainMod SHIFT, E,      exec, emacsclient -c -a 'emacs'
bind = $mainMod,       C,      exec, st -e zsh -c 'khal interactive'
bind = $mainMod,       M,      exec, st -e zsh -c 'neomutt'

# Menu hoykeys
bind = $mainMod, R, exec, fuzzel

# System control keybinds
binde = $mainMod,       MINUS, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%-
binde = $mainMod SHIFT, MINUS, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-
binde = $mainMod,       EQUAL, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%+
binde = $mainMod SHIFT, EQUAL, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+
binde = ,F7,                   exec, change-brightness up
binde = ,XF86MonBrightnessUp,  exec, change-brightness up
binde = ,F6,                   exec, change-brightness down
binde = ,XF86MonBrightnessDown,exec, change-brightness down
bind  = $mainMod,       L,     exec, hyprlock
bind  = $mainMod CONTROL SHIFT, R, exec, startw # Reload all graphical daemons


# Print area, screen, and all, respectively
bind  = $mainMod,               P, exec, menu-screenshot area
bind  = $mainMod SHIFT,         P, exec, menu-screenshot output
bind  = $mainMod CONTROL SHIFT, P, exec, menu-screenshot screen

# Launch menu scripts with Super-D keychord
bind = $mainMod, D, exec, hyprctl dispatch submap menu-submap; sleep 2; hyprctl dispatch submap reset
submap = menu-submap
bind = ,A, exec, menu-accent
bind = ,A, submap, reset
bind = ,B, exec, [floating] foot -W 80x17 -e dash -c -i 'menu-bookmark'
bind = ,B, submap, reset
bind = ,M, exec, [floating] foot -W 78x38 -e dash -c -i 'menu-man'
bind = ,M, submap, reset
bind = ,W, exec, networkmanager_dmenu
bind = ,W, submap, reset
bind = ,O, exec, menu-wpio sink
bind = ,O, submap, reset
bind = ,I, exec, menu-wpio source
bind = ,I, submap, reset
bind = ,L, exec, hyprmonitors menu
bind = ,L, submap, reset
bind = ,P, exec, [floating] foot -W 80x17 -e zsh -c -i 'menu-pass'
bind = ,P, submap, reset
submap = reset

# Hide waybar
bind = $mainMod, B, exec, pkill -SIGUSR1 waybar

# Kill commands
bind = $mainMod CONTROL SHIFT, Q, exit, 
bind = $mainMod,               Q, killactive, 

# Change gaps
binde = $mainMod,       Z, exec, hyprgaps -c 3
binde = $mainMod,       X, exec, hyprgaps -c -3
bind  = $mainMod,       A, exec, hyprgaps -t
bind  = $mainMod SHIFT, A, exec, hyprgaps -r

# Master stack movement commands
bind = $mainMod,       J, layoutmsg, cyclenext
bind = $mainMod SHIFT, J, layoutmsg, swapnext
bind = $mainMod,       K, layoutmsg, cycleprev
bind = $mainMod SHIFT, K, layoutmsg, swapprev
bind = $mainMod SHIFT, L, splitratio, +0.05
bind = $mainMod SHIFT, H, splitratio, -0.05

# Changing number of masters
bind = $mainMod,       O, layoutmsg, addmaster
bind = $mainMod SHIFT, O, layoutmsg, removemaster

# Change tiling direction
bind = $mainMod,       T, layoutmsg, orientationleft
bind = $mainMod SHIFT, T, layoutmsg, orientationtop

# Special windows
bind = $mainMod,       F, togglefloating, 
bind = $mainMod,       F, resizeactive, exact 50% 50%
bind = $mainMod SHIFT, F, fullscreenstate, 0, 2
bind = $mainMod,       S, togglespecialworkspace, magic
bind = $mainMod SHIFT, S, movetoworkspace, special:magic

# Switch workspaces with mainMod + [0-9]
bind = $mainMod, 1, exec, hyprdwm goto 1
bind = $mainMod, 2, exec, hyprdwm goto 2
bind = $mainMod, 3, exec, hyprdwm goto 3
bind = $mainMod, 4, exec, hyprdwm goto 4
bind = $mainMod, 5, exec, hyprdwm goto 5
bind = $mainMod, 6, exec, hyprdwm goto 6
bind = $mainMod, 7, exec, hyprdwm goto 7
bind = $mainMod, 8, exec, hyprdwm goto 8
bind = $mainMod, 9, exec, hyprdwm goto 9
bind = $mainMod, 0, exec, hyprdwm goto 10

# Move active window to a workspace with mainMod + SHIFT + [0-9]
bind = $mainMod SHIFT, 1, exec, hyprdwm moveto 1
bind = $mainMod SHIFT, 2, exec, hyprdwm moveto 2
bind = $mainMod SHIFT, 3, exec, hyprdwm moveto 3
bind = $mainMod SHIFT, 4, exec, hyprdwm moveto 4
bind = $mainMod SHIFT, 5, exec, hyprdwm moveto 5
bind = $mainMod SHIFT, 6, exec, hyprdwm moveto 6
bind = $mainMod SHIFT, 7, exec, hyprdwm moveto 7
bind = $mainMod SHIFT, 8, exec, hyprdwm moveto 8
bind = $mainMod SHIFT, 9, exec, hyprdwm moveto 9
bind = $mainMod SHIFT, 0, exec, hyprdwm moveto 10

# Moving windows between monitors
bind = $mainMod SHIFT, COMMA,  movewindow, mon:+1
bind = $mainMod SHIFT, PERIOD, movewindow, mon:-1
bind = $mainMod SHIFT, LEFT,   movewindow, mon:l
bind = $mainMod SHIFT, RIGHT,  movewindow, mon:r
bind = $mainMod SHIFT, UP,     movewindow, mon:u
bind = $mainMod SHIFT, DOWN,   movewindow, mon:d

# Moving focus between monitors
bind = $mainMod, COMMA,  exec, hyprctl dispatch focusmonitor +1
bind = $mainMod, PERIOD, exec, hyprctl dispatch focusmonitor -1
bind = $mainMod, LEFT,   exec, hyprctl dispatch focusmonitor l
bind = $mainMod, RIGHT,  exec, hyprctl dispatch focusmonitor r
bind = $mainMod, UP,     exec, hyprctl dispatch focusmonitor u
bind = $mainMod, DOWN,   exec, hyprctl dispatch focusmonitor d

# Put floating window on all workspaces
bind = $mainMod, Y, pin

# Scroll through existing workspaces with mainMod + scroll
bind = $mainMod, mouse_down, workspace, e+1
bind = $mainMod, mouse_up,   workspace, e-1

# Move/resize windows with mainMod + LMB/RMB and dragging
bindm = $mainMod, mouse:272, movewindow
bindm = $mainMod, mouse:273, resizewindow

exec-once = startw

