# Hyprland Configuration
# Device: {{ .deviceProfile }} ({{ .hostname }})
# Managed by chezmoi - edit source at ~/dotfiles

source = ~/.config/hypr/colors.conf
source = ~/.config/hypr/autostart.conf
source = ~/.config/hypr/workspaces.conf
source = ~/.config/hypr/monitors.conf

################
### MONITORS ###
################

# Monitor configuration is in monitors.conf (device-specific)

###################
### MY PROGRAMS ###
###################

$terminal = ghostty
$fileManager = thunar
$menu = wofi --show drun
$run_menu = wofi --show run

#############################
### ENVIRONMENT VARIABLES ###
#############################

env = XCURSOR_SIZE,24
env = HYPRCURSOR_SIZE,24

#####################
### LOOK AND FEEL ###
#####################

general {
    gaps_in = 2
    gaps_out = 5
    border_size = 2
    col.active_border = rgba(33ccffee) rgba(00ff99ee) 45deg
    col.inactive_border = rgba(595959aa)
    resize_on_border = false
    allow_tearing = false
    layout = dwindle
}

decoration {
    rounding = 10
    rounding_power = 2
    active_opacity = 1.0
    inactive_opacity = 1.0

    shadow {
        enabled = true
        range = 4
        render_power = 3
        color = rgba(1a1a1aee)
    }

    blur {
        enabled = true
        size = 3
        passes = 1
        vibrancy = 0.1696
    }
}

animations {
    enabled = yes

    bezier = easeOutQuint,0.23,1,0.32,1
    bezier = easeInOutCubic,0.65,0.05,0.36,1
    bezier = linear,0,0,1,1
    bezier = almostLinear,0.5,0.5,0.75,1.0
    bezier = quick,0.15,0,0.1,1
    bezier = snappy,0.2,0.8,0.2,1
    bezier = overshoot,0.34,1.56,0.64,1
    bezier = bounce,0.68,-0.55,0.27,1.55
    bezier = whip,0.1,0.9,0.2,1

    animation = global, 1, 5, default
    animation = border, 1, 2.5, snappy
    animation = windows, 1, 2.8, easeOutQuint
    animation = windowsIn, 1, 2.2, bounce, popin 95%
    animation = windowsOut, 1, 0.9, whip, popin 85%
    animation = fadeIn, 1, 0.9, snappy
    animation = fadeOut, 1, 0.8, snappy
    animation = fade, 1, 1.6, quick
    animation = layers, 1, 2.0, easeOutQuint
    animation = layersIn, 1, 1.8, bounce, fade
    animation = layersOut, 1, 0.8, whip, fade
    animation = fadeLayersIn, 1, 0.9, snappy
    animation = fadeLayersOut, 1, 0.7, snappy
    animation = workspaces, 1, 1.2, bounce, fade
    animation = workspacesIn, 1, 0.9, overshoot, fade
    animation = workspacesOut, 1, 1.0, whip, fade
}

# Smart gaps window rules
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]

# Quick Memo popup (yad)
windowrulev2 = float, class:^(yad)$
windowrulev2 = center, class:^(yad)$
windowrulev2 = pin, class:^(yad)$

binds {
    hide_special_on_workspace_change = true
    workspace_back_and_forth = true
}

ecosystem {
    enforce_permissions = true
}

dwindle {
    pseudotile = true
    preserve_split = true
}

master {
    new_status = master
}

misc {
    force_default_wallpaper = -1
    disable_hyprland_logo = false
    enable_anr_dialog = false
}

#############
### INPUT ###
#############

input {
    kb_layout = us, ru
    kb_variant =
    kb_model =
    kb_options = caps:escape
    kb_rules =
    numlock_by_default = true
    follow_mouse = 1
    sensitivity = 0

{{- if .hasTouchpad }}
    touchpad {
        natural_scroll = true
        tap-to-click = true
        disable_while_typing = true
    }
}

gestures {
    workspace_swipe = true
    workspace_swipe_fingers = 3
}
{{- else }}
    touchpad {
        natural_scroll = false
    }
}
{{- end }}

device {
    name = epic-mouse-v1
    sensitivity = -0.5
}

###################
### KEYBINDINGS ###
###################

$mainMod = SUPER

# Keyboard layout toggle (us/ru)
bind = SUPER, SPACE, exec, hyprctl switchxkblayout all next

# Wallpapers
bind = SUPER, bracketright, exec, ~/Scripts/change_wallpaper.sh next
bind = SUPER, bracketleft, exec, ~/Scripts/change_wallpaper.sh prev

# Core bindings
bind = $mainMod, Q, exec, $terminal
bind = $mainMod, K, killactive,
bind = $mainMod, M, exit,
bind = $mainMod, E, exec, ~/.local/bin/hypr-expo
bind = $mainMod, V, togglefloating,
bind = $mainMod, R, exec, $menu
bind = $mainMod SHIFT, R, exec, hyprctl reload
bind = $mainMod, P, pseudo,
bind = $mainMod, J, togglesplit,
bind = $mainMod, L, exec, hyprctl switchxkblayout all 0 && pactl set-sink-mute @DEFAULT_SINK@ 1 && hyprlock
bind = $mainMod, t, togglegroup

# VPN switcher
bind = , F6, exec, ~/.local/bin/vpn-switcher

# Move focus with mainMod + arrow keys
bind = $mainMod, left, movefocus, l
bind = $mainMod, right, movefocus, r
bind = $mainMod, up, movefocus, u
bind = $mainMod, down, movefocus, d

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

# Special workspaces
bind = SUPER, F12, exec, ~/.local/bin/workspace-pin 1337
bind = SUPER, A, togglespecialworkspace, org
bind = SUPER SHIFT, A, movetoworkspace, special:org

# Quick Memo (jax-bot integration)
bind = , F12, exec, ~/.local/bin/quick-memo --input
bind = SHIFT, F12, exec, ~/.local/bin/quick-memo --clipboard
bind = SUPER, X, workspace, name:media
bind = SUPER SHIFT, X, movetoworkspace, name:media
bind = SUPER SHIFT, C, movetoworkspace, name:tg
bind = SUPER, c, workspace, name:tg
bind = $mainMod, S, togglespecialworkspace, termius
bind = $mainMod SHIFT, S, movetoworkspacesilent, special:termius
bind = $mainMod, G, togglespecialworkspace, llm
bind = $mainMod SHIFT, G, movetoworkspacesilent, special:llm

# Move active window to workspace
bind = $mainMod SHIFT, 1, movetoworkspacesilent, 1
bind = $mainMod SHIFT, 2, movetoworkspacesilent, 2
bind = $mainMod SHIFT, 3, movetoworkspacesilent, 3
bind = $mainMod SHIFT, 4, movetoworkspacesilent, 4
bind = $mainMod SHIFT, 5, movetoworkspacesilent, 5
bind = $mainMod SHIFT, 6, movetoworkspacesilent, 6
bind = $mainMod SHIFT, 7, movetoworkspacesilent, 7
bind = $mainMod SHIFT, 8, movetoworkspacesilent, 8
bind = $mainMod SHIFT, 9, movetoworkspacesilent, 9
bind = $mainMod SHIFT, 0, movetoworkspacesilent, 10

# Screenshot (selection, copies to clipboard)
bind = , Print, exec, ~/.local/bin/screenshot

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

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

# Media keys
bindel = ,XF86AudioRaiseVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+
bindel = ,XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-
bindel = ,XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle
bindel = ,XF86AudioMicMute, exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle
{{- if .hasBattery }}
bindel = ,XF86MonBrightnessUp, exec, brightnessctl s 10%+
bindel = ,XF86MonBrightnessDown, exec, brightnessctl s 10%-
{{- end }}
bindl = , XF86AudioNext, exec, playerctl next
bindl = , XF86AudioPause, exec, playerctl play-pause
bindl = , XF86AudioPlay, exec, playerctl play-pause
bindl = , XF86AudioPrev, exec, playerctl previous

##############################
### WINDOWS AND WORKSPACES ###
##############################

# Window rules for apps
windowrulev2 = workspace name:tg, class:^(org.telegram.desktop)$
windowrulev2 = workspace name:tg, class:^(discord)$
windowrulev2 = suppressevent maximize, class:.*
windowrulev2 = nofocus,class:^$,title:^$,xwayland:1,floating:1,fullscreen:0,pinned:0

#############
### PLUGINS ###
#############

plugin {
    hyprexpo {
        columns = 3
        gap_size = 5
        bg_col = rgb(111111)
        workspace_method = first 1
{{- if .hasTouchpad }}
        enable_gesture = true
        gesture_fingers = 3
        gesture_distance = 300
        gesture_positive = true
{{- else }}
        enable_gesture = false
{{- end }}
    }
}
