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

# See https://wiki.hyprland.org/Configuring/Monitors/
monitor=eDP-1, 1920x1080, 0x0, 1
monitor=HDMI-A-1, 1920x1080, -1920x-100, 1

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

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

# Set programs that you use
$terminal = kitty
$fastTerminal = kitty --single-instance
$fileManager = thunar
$menu = $HOME/.config/rofi-wayland/launchers/type-6/launcher.sh
$browser = env GTK_THEME=Adwaita:light zen-browser
$privateBrowser = env GTK_THEME=Adwaita:light zen-browser --private-window
$passwordManager = keepassxc

#################
### AUTOSTART ###
#################

# Autostart necessary processes (like notifications daemons, status bars, etc.)
# Or execute your favorite apps at launch like this:

# Le essential hyprland crap
exec-once = hyprpaper
exec-once = waybar & hypridle & hyprsunset &
exec-once = swaync
exec-once = ~/.config/hypr/scripts/random_wallpaper.sh
exec-once = ~/.config/hypr/scripts/autofreezer.sh

# exec-once = systemctl --user startexec-once=dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP hyprpaper.service
exec-once = libinput-gestures
exec-once = copyq --start-server
exec-once = /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 &
exec-once = thunar --daemon &
exec-once = touch /tmp/toggle_ssocks
exec-once = ~/.config/bspwm/proxy.sh &
exec-once = nextcloud --background &
exec-once = [workspace 8 silent] Telegram 
# exec-once = [workspace 7 silent] superproductivity
# exec-once = $terminal
# exec-once = nm-applet &
# exec-once = waybar & hyprpaper & firefox


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

# See https://wiki.hyprland.org/Configuring/Environment-variables/

env = XCURSOR_SIZE,24
env = HYPRCURSOR_SIZE,24

###################
### PERMISSIONS ###
###################

# See https://wiki.hyprland.org/Configuring/Permissions/
# Please note permission changes here require a Hyprland restart and are not applied on-the-fly
# for security reasons

# ecosystem {
#   enforce_permissions = 1
# }

# permission = /usr/(bin|local/bin)/grim, screencopy, allow
# permission = /usr/(lib|libexec|lib64)/xdg-desktop-portal-hyprland, screencopy, allow
# permission = /usr/(bin|local/bin)/hyprpm, plugin, allow


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

# Refer to https://wiki.hyprland.org/Configuring/Variables/

# https://wiki.hyprland.org/Configuring/Variables/#general
general {
    gaps_in = 12.5
    gaps_out = 20

    border_size = 3

    # https://wiki.hyprland.org/Configuring/Variables/#variable-types for info about colors
    col.active_border = rgba(E96375ff) rgba(9E2238ff) 45deg
    col.inactive_border = rgba(4B535Bff) # rgba(595959aa)

    # Set to true enable resizing windows by clicking and dragging on borders and gaps
    resize_on_border = false

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

    layout = dwindle

    no_focus_fallback = true

    snap {
      enabled = true
    }

}

# https://wiki.hyprland.org/Configuring/Variables/#decoration
decoration {
    rounding = 10
    rounding_power = 2

    # Change transparency of focused and unfocused windows
    active_opacity = 1.0
    inactive_opacity = 1.0

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

    # https://wiki.hyprland.org/Configuring/Variables/#blur
    blur {
        enabled = true
        size = 5
        passes = 1

        vibrancy = 0.1696
    }
}

group {
  col.border_active = rgba(E96375ff) rgba(EB75FFff) 45deg
  col.border_inactive = rgba(F9730032) rgba(FB850032) 45deg
  # col.border_locked_active = rgba(E96375ff) rgba(EB75FFff) 45deg
  # col.border_locked_inactive = rgba(E96375ff) rgba(EB75FFff) 45deg
  groupbar {
    # font_size = 12
    text_color = rgba(ffffff00)
    render_titles = false 
    indicator_height = 10
    rounding = 5
    round_only_edges = false
    col.active = rgba(F8859Eff)
    col.inactive = rgba(32323264) rgba(32323264) 45deg
    gaps_in = 5
    gaps_out = 5

  }
}

source = ~/.config/hypr/grayscale.conf

# https://wiki.hyprland.org/Configuring/Variables/#animations
animations {
    enabled = yes, please :)

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

    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

    animation = global, 1, 10, default
    animation = border, 1, 5.39, easeOutQuint
    animation = windows, 1, 4.79, easeOutQuint
    animation = windowsIn, 1, 4.1, easeOutQuint, popin 87%
    animation = windowsOut, 1, 1.49, linear, popin 87%
    animation = fadeIn, 1, 1.73, almostLinear
    animation = fadeOut, 1, 1.46, almostLinear
    animation = fade, 1, 3.03, quick
    animation = layers, 1, 3.81, easeOutQuint
    animation = layersIn, 1, 4, easeOutQuint, fade
    animation = layersOut, 1, 1.5, linear, fade
    animation = fadeLayersIn, 1, 1.79, almostLinear
    animation = fadeLayersOut, 1, 1.39, almostLinear
    animation = workspaces, 1, 1.94, almostLinear, fade
    animation = workspacesIn, 1, 1.21, almostLinear, fade
    animation = workspacesOut, 1, 1.94, almostLinear, fade
    animation = layers, 1, 7, default, slide
}

# Ref https://wiki.hyprland.org/Configuring/Workspace-Rules/
# "Smart gaps" / "No gaps when only"
# uncomment all if you wish to use that.
# workspace = w[tv1], gapsout:0, gapsin:0
# workspace = f[1], gapsout:0, gapsin:0
workspace = 1, monitor:eDP-1
workspace = 2, monitor:eDP-1
workspace = 3, monitor:eDP-1
workspace = 4, monitor:eDP-1
workspace = 5, monitor:eDP-1
workspace = 6, monitor:eDP-1
workspace = 7, monitor:eDP-1
workspace = 8, monitor:eDP-1
workspace = 9, monitor:eDP-1
workspace = 10, monitor:HDMI-A-1
workspace = 11, monitor:HDMI-A-1
workspace = 12, monitor:HDMI-A-1
workspace = 13, monitor:eDP-1
workspace = 14, monitor:HDMI-A-1
workspace = 13, on-created-empty:hyprctl dispatch workspace 1
workspace = 14, on-created-empty:hyprctl dispatch workspace 10

# workspace = 14, on-created-empty:

# windowrule = bordersize 0, floating:0, onworkspace:w[tv1]
# windowrule = rounding 0, floating:0, onworkspace:w[tv1]
# windowrule = bordersize 0, floating:0, onworkspace:f[1]
# windowrule = rounding 0, floating:0, onworkspace:f[1]

# See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more
dwindle {
    pseudotile = true # Master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below
    preserve_split = true # You probably want this
    smart_resizing = false
    force_split = 2
}

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

# https://wiki.hyprland.org/Configuring/Variables/#misc
misc {
    force_default_wallpaper = 1 # Set to 0 or 1 to disable the anime mascot wallpapers
    disable_hyprland_logo = true # If true disables the random hyprland logo / anime girl background. :(
    vfr = true
    animate_manual_resizes = true
    enable_swallow = true
    middle_click_paste = false
    enable_anr_dialog = false
  
}


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

# https://wiki.hyprland.org/Configuring/Variables/#input
input {
    kb_layout= us,ru
    kb_options= grp:caps_toggle,grp_led:caps
    # kb_variant = ,qwerty
    # kb_model =
    # kb_rules =

    follow_mouse = 0 # 2
    float_switch_override_focus = 0
    sensitivity = 0.2 # -1.0 - 1.0, 0 means no modification.

    touchpad {
        natural_scroll = true
        disable_while_typing = true
        middle_button_emulation = true
    }
}

# https://wiki.hyprland.org/Configuring/Variables/#gestures
gestures {
  gesture = 3, horizontal, scale: 2, workspace
}

# Example per-device config
# See https://wiki.hyprland.org/Configuring/Keywords/#per-device-input-configs for more
device {
    name = epic-mouse-v1
    sensitivity = -0.5
}


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

# See https://wiki.hyprland.org/Configuring/Keywords/
$mainMod = SUPER # Sets "Windows" key as main modifier

# Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more
bind = $mainMod ALT, Q, exit,
bind = $mainMod SHIFT, delete, exec, shutdown now

# Open programs
bind = $mainMod, Return, exec, $terminal
bind = $mainMod, E, exec, $fileManager
bind = $mainMod, Q, exec, $browser
bind = $mainMod SHIFT, Q, exec, $privateBrowser
bind = $mainMod, Backslash, exec, $fastTerminal
bind = $mainMod, Space, exec, $menu
bind = $mainMod, X, exec, $passwordManager
bind = $mainMod, N, exec, swaync-client -t -sw

# Open floating terminal
bind = $mainMod SHIFT, Return, exec, [float; size 800 600; move center] $fastTerminal --class kitty-float

# Open bluetooth
bind = $mainMod, F3, exec, [float; size 600 400; move center] $fastTerminal --class kitty-float bluetuith

# Open alsamixer
bind = $mainMod, F2, exec, [float; size 600 400; move center] $fastTerminal --class kitty-float alsamixer -V all

# Open ncmpcpp
bind = $mainMod, F1, exec, [float; size 600 400; move center] $fastTerminal --class kitty-float ncmpcpp

# Close window
binde = $mainMod, W, killactive,

# Kill window
binde = $mainMod SHIFT, W, forcekillactive,

# Change window modes
bind = $mainMod, S, togglefloating,
bind = $mainMod, T, settiled,
bind = $mainMod, F, fullscreen,
bind = $mainMod CTRL, P, pin,

# Bring to top
bind = $mainMod, Z, bringactivetotop

# Make window float and center it
bind = $mainMod SHIFT, S, setfloating,
bind = $mainMod SHIFT, S, resizeactive, exact 800 600
bind = $mainMod SHIFT, S, centerwindow,

bind = $mainMod, P, pseudo, # dwindle
bind = $mainMod, D, togglesplit, # dwindle
# bind = $mainMod SHIFT, Print, exec, IMG=~/Pictures/Screenshots/$(date +%Y-%m-%d_%H-%m-%s).png grim -g "$(slurp -d)" - | swappy -f -
# bind = $mainMod, Print, exec, IMG=~/Pictures/Screenshots/$(date +%Y-%m-%d_%H-%m-%s).png && grim -g "$(slurp)" $IMG && wl-copy < $IMG 
bind = $mainMod SHIFT, Print, exec, grimblast --freeze copysave area ~/Pictures/Screenshots/$(date +%Y-%m-%d_%H-%m-%s).jpg && play ~/Templates/Sounds/photo.mp3
bind = $mainMod, Print, exec, play ~/Templates/Sounds/photo.mp3 & grimblast --freeze copysave output ~/Pictures/Screenshots/$(date +%Y-%m-%d_%H-%m-%s).jpg 

# Move focus with mainMod + arrow keys
bind = $mainMod, h, movefocus, l
bind = $mainMod, l, movefocus, r
bind = $mainMod, k, movefocus, u
bind = $mainMod, j, 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
bind = $mainMod, 0, workspace, 10
bind = $mainMod, minus, workspace, 11
bind = $mainMod, equal, workspace, 12

# Move active window to a workspace with mainMod + SHIFT + [0-9]
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
bind = $mainMod SHIFT, minus, movetoworkspacesilent, 11
bind = $mainMod SHIFT, equal, movetoworkspacesilent, 12

# Cycle monitors
bind = $mainMod SHIFT, U, swapactiveworkspaces, eDP-1 HDMI-A-1
bind = $mainMod, O, focusmonitor, +1

# Example special workspace (scratchpad)
bind = $mainMod, M, togglespecialworkspace, magic
bind = $mainMod SHIFT, M, movetoworkspace, special:magic

# Scroll through existing workspaces with mainMod + scroll
bind = $mainMod, bracketleft, workspace, r-1
bind = $mainMod, bracketright, workspace, r+1
bind = $mainMod SHIFT, bracketleft, workspace, m-1
bind = $mainMod SHIFT, bracketright, workspace, m+1

bind = $mainMod, grave, togglespecialworkspace, dungeon
bind = $mainMod SHIFT, grave, movetoworkspace, special:dungeon

# Cringy mouse movement
binde = $mainMod ALT, up, exec, ~/.config/hypr/scripts/weirdmouse.sh up
binde = $mainMod ALT, down, exec, ~/.config/hypr/scripts/weirdmouse.sh down
binde = $mainMod ALT, left, exec, ~/.config/hypr/scripts/weirdmouse.sh left
binde = $mainMod ALT, right, exec, ~/.config/hypr/scripts/weirdmouse.sh right

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

# Move windows with keyboard
bind = $mainMod SHIFT, h, swapwindow, l
bind = $mainMod SHIFT, l, swapwindow, r
bind = $mainMod SHIFT, j, swapwindow, d
bind = $mainMod SHIFT, k, swapwindow, u

# Cycle through windows with mainMod + C
bind = $mainMod, C, cyclenext
bind = $mainMod SHIFT, C, cyclenext, prev

# Go to previous window and back
bind = ALT, TAB, focuscurrentorlast
bind = $mainMod, I, focusurgentorlast
bind = $mainMod, Tab, workspace, previous

# Resize windows in different directions via keyboard
binde = $mainMod ALT, h, resizeactive, -60 0
binde = $mainMod ALT, l, resizeactive, 60 0
binde = $mainMod ALT, j, resizeactive, 0 60
binde = $mainMod ALT, k, resizeactive, 0 -60
binde = $mainMod ALT SHIFT, h, resizeactive, 60 0
binde = $mainMod ALT SHIFT, l, resizeactive, -60 0
binde = $mainMod ALT SHIFT, j, resizeactive, 0 -60
binde = $mainMod ALT SHIFT, k, resizeactive, 0 60

# Swap windows in different directions via keyboard
binde = $mainMod, Left, moveactive, -100 0
binde = $mainMod, Right, moveactive, 100 0
binde = $mainMod, Down, moveactive, 0 100
binde = $mainMod, Up, moveactive, 0 -100

# Move windows in different directions via keyboard
bind = $mainMod SHIFT, Left, movewindow, l
bind = $mainMod SHIFT, Right, movewindow, r
bind = $mainMod SHIFT, Down, movewindow, d
bind = $mainMod SHIFT, Up, movewindow, u

# Receptacles
bind = $mainMod CTRL, H, layoutmsg, preselect l 
bind = $mainMod CTRL, L, layoutmsg, preselect r
bind = $mainMod CTRL, J, layoutmsg, preselect d
bind = $mainMod CTRL, K, layoutmsg, preselect u

# Toggle layout type
bind = $mainMod SHIFT, X, exec, hyprctl keyword general:layout "$(hyprctl getoption general:layout | grep -q 'dwindle' && echo 'master' || echo 'dwindle')"

# Window grouping
bind = $mainMod CTRL ALT, M, togglegroup
bind = $mainMod, comma, changegroupactive, b 
bind = $mainMod, period, changegroupactive, f
bind = $mainMod CTRL ALT, Up, movewindoworgroup, u
bind = $mainMod CTRL ALT, Down, movewindoworgroup, d 
bind = $mainMod CTRL ALT, Left, movewindoworgroup, l
bind = $mainMod CTRL ALT, Right, movewindoworgroup, r

# Laptop multimedia keys for volume and LCD brightness
bindel = ,XF86AudioRaiseVolume, exec, wpctl set-volume -l 1 @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
bindel = ,XF86MonBrightnessUp, exec, brightnessctl -e4 -n2 set 5%+
bindel = ,XF86MonBrightnessDown, exec, brightnessctl -e4 -n2 set 5%-

# Requires playerctl
bindl = , XF86AudioNext, exec, playerctl next
bindl = , XF86AudioPause, exec, playerctl play-pause
bindl = , XF86AudioPlay, exec, playerctl play-pause
bindl = , XF86AudioPrev, exec, playerctl previous

# Toggle waybar
bind = $mainMod SHIFT, B, exec, ~/.config/hypr/scripts/toggle_waybar.sh

# Toggle grayscale mode
bind = $mainMod CTRL, G, exec, ~/.config/hypr/scripts/grayscale-toggle.sh

# Game mode
bind = $mainMod SHIFT, G, exec, ~/.config/hypr/scripts/gamemode.sh

# Cycle cpu frequency mode
bind = $mainMod CTRL, C, exec, ~/.config/hypr/scripts/cpufreq.sh

# Pin window
bind = $mainMod CTRL, Y, pin, active

# Mark window
bind = $mainMod CTRL, M, tagwindow, marked

# Close marked windows
bind = $mainMod CTRL, W, exec, ~/.config/hypr/scripts/close_marked.sh

# Move marked to current workspace
bind = $mainMod, Y, exec, ~/.config/hypr/scripts/move_marked.sh

# Freeze window
bind = $mainMod SHIFT, T, exec, hyprfreeze -a -s 
bind = $mainMod SHIFT, F, tagwindow, zawarudo

# Lock screen
bind = $mainMod, Backspace, exec, hyprlock

bind = $mainMod SHIFT, Backspace, exec, shutdown now 

# Discord PTT
bindr = , F8, sendshortcut, CTRL SHIFT, F8, class:^(vesktop)$

# Telegram PTT
binde = $mainMod CTRL, F9, tagwindow, voicechatuz 
bindr = , F9, sendshortcut, , F9, class:TelegramDesktop
windowrule = bordercolor rgba(ffff00ff) rgba(ffff0055),tag:voicechatuz

# Disable binds temporarily
bind = $mainMod, Escape, submap, clean
submap = clean
bind = $mainMod, Escape, submap, reset
submap = reset

# bindr = , F8, sendshortcut, , Space, title:^(ready\ or\ тундра\.\.\.)$
# bindr = , F8, sendshortcut, , Space, title:^(КОМАНДА\ Эспада)$

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

# See https://wiki.hyprland.org/Configuring/Window-Rules/ for more
# See https://wiki.hyprland.org/Configuring/Workspace-Rules/ for workspace rules

# Floating kitty
windowrule = float,class:^(kitty-float)$
windowrule = size 600 400,class:^(kitty-float)$
windowrule = move center,class:^(kitty-float)$

# Zenity
windowrule = float,class:^(zenity)$

# Super Productivity
windowrule = workspace 7 silent,class:^(superProductivity)$

# Telegram
windowrule = workspace 8 silent,class:^(TelegramDesktop)$
windowrule = group override set always,class:^(TelegramDesktop)$
windowrule = workspace 8 silent,class:^(org.telegram.desktop)$
windowrule = group override set always,class:^(org.telegram.desktop)$

# Vesktop
windowrule = workspace 8 silent,class:^(vesktop)$
windowrule = group override set always,class:^(vesktop)$

# Nextcloud
windowrule = float,animation slide top,resize 800 600,move center,class:^(com.nextcloud.desktopclient.nextcloud)$

# com.saivert.pwvucontrol
windowrule = float,class:^(com.saivert.pwvucontrol)$
windowrule = size 600 400,class:^(com.saivert.pwvucontrol)$
windowrule = move center,class:^(com.saivert.pwvucontrol)$

# Frozen windows
windowrule = bordercolor rgba(E96375ff) rgba(00ffff55) 90deg,tag:zawarudo

# Marked windows
windowrule = bordercolor rgba(0000ffff) rgba(aa00ffa5),tag:marked

# Ignore maximize requests from apps. You'll probably like this.
windowrule = suppressevent maximize, class:.*

# Fix some dragging issues with XWayland
windowrule = nofocus,class:^$,title:^$,xwayland:1,floating:1,fullscreen:0,pinned:0

layerrule = blur, rofi
layerrule = animation slideIn left, rofi

layerrule = blur, swaync-control-center

layerrule = blur, waybar
layerrule = animation slideIn right, swaync-control-center

workspace = special:magic, gapsin:20, gapsout:50, shadow:false
workspace = 9, gapsin:15, gapsout:40 

debug {
  disable_logs = false
}
