#-- Input ----------------------------------------------------
# Configure mouse and touchpad here.
input {
    kb_layout=us
    kb_variant=
    kb_model=
    kb_options=
    kb_rules=
    
    # mouse focus will not switch to the hovered window unless the mouse crosses a window boundary
    follow_mouse=1
    mouse_refocus=false

    natural_scroll=0
    touchpad {
        natural_scroll = 1
    }
	force_no_accel=0
    # repeat_rate=
    # repeat_delay=
    numlock_by_default=1
}

#-- General ----------------------------------------------------
# General settings like MOD key, Gaps, Colors, etc.
general {
    gaps_in=5
    gaps_out=10

    border_size=4
    col.active_border=0xFFB4A1DB
    col.inactive_border=0xFF343A40
}

#-- Decoration ----------------------------------------------------
# Decoration settings like Rounded Corners, Opacity, Blur, etc.
decoration {
    rounding=8       # Original: rounding=-1

    active_opacity=1.0
    inactive_opacity=0.9
    fullscreen_opacity=1.0

    blur {
        enabled=true
        size=3                	# minimum 1
        passes=1                # minimum 1, more passes = more resource intensive.
        ignore_opacity=false
    }

    # Your blur "amount" is blur_size * blur_passes, but high blur_size (over around 5-ish) will produce artifacts.
    # if you want heavy blur, you need to up the blur_passes.
    # the more passes, the more you can up the blur_size without noticing artifacts.
}

#-- Animations ----------------------------------------------------
animations {
    enabled=1
    # animation=NAME,ONOFF,SPEED,CURVE,STYLE
    animation=windows,1,8,default,popin 80%
    animation=fadeOut,1,8,default
    animation=fadeIn,1,8,default
    animation=workspaces,1,8,default
    #animation=workspaces,1,6,overshot
}

#-- Dwindle ----------------------------------------------------
dwindle {
    pseudotile=0 			# enable pseudotiling on dwindle
}

#-- Window Rules ----------------------------------------------------
windowrule=float,         class:^(yad|nm-connection-editor|pavucontrolk)$
windowrule=float,         class:^(xfce-polkit|kvantummanager|qt5ct)$
windowrule=float,         class:^(feh|imv|Gpicview|Gimp|nomacs)$
windowrule=float,         class:^(VirtualBox Manager|qemu|Qemu-system-x86_64)$
windowrule=float,         class:^(xfce4-appfinder)$

# foot
windowrule=float,         class:^(foot-float)$
windowrule=float,         class:^(foot-full)$
windowrule=move 0 0,      class:^(foot-full)$
windowrule=size 100% 100%,class:^(foot-full)$

# flameshot
windowrule = move 0 0,class:(flameshot)
windowrule = pin,class:(flameshot)
windowrule = noborder,class:(flameshot)
windowrule = stayfocused,class:(flameshot)
windowrule = float,class:(flameshot)

# avoid transparency
windowrule = opaque,class:(flameshot)

# wlogout
windowrule=float,class:^(wlogout)$
windowrule=move 0 0,class:^(wlogout)$
windowrule=size 100% 100%,class:^(wlogout)$
windowrule=animation slide,class:^(wlogout)$

#-- Keybindings ----------------------------------------------------
$term = foot
$app_launcher = ~/.config/hypr/scripts/menu
$volume = ~/.config/hypr/scripts/volume
$backlight = ~/.config/hypr/scripts/brightness
$lockscreen = ~/.config/hypr/scripts/lockscreen
$wlogout = ~/.config/hypr/scripts/wlogout
$colorpicker = ~/.config/hypr/scripts/colorpicker
$files = thunar
$browser = firefox

# -- Terminal --
bind=SUPER,Return,exec,$term

# -- App Launcher --
bind=SUPER,D,exec,$app_launcher

# -- Hyprland --
bind=SUPER,Q,killactive,
bind=CTRLALT,Delete,exit,
bind=SUPER,F,fullscreen,
bind=SUPER,Space,togglefloating,
bind=SUPER,S,pseudo,

# -- Misc --
bind=SUPER,N,exec,nm-connection-editor  # need install network-manager-applet
bind=SUPER,P,exec,$colorpicker
bind=CTRLALT,L,exec,$lockscreen
bind=SUPERSHIFT,X,exec,$wlogout

# -- Some nice mouse binds --
bindm=SUPER,mouse:272,movewindow
bindm=SUPER,mouse:273,resizewindow

# -- Function keys --
bind=,XF86MonBrightnessUp,exec,$backlight --inc
bind=,XF86MonBrightnessDown,exec,$backlight --dec
bind=,XF86AudioRaiseVolume,exec,$volume --inc
bind=,XF86AudioLowerVolume,exec,$volume --dec
bind=,XF86AudioMute,exec,$volume --toggle
bind=,XF86AudioMicMute,exec,$volume --toggle-mic
bind=,XF86AudioNext,exec,mpc next
bind=,XF86AudioPrev,exec,mpc prev
bind=,XF86AudioPlay,exec,mpc toggle
bind=,XF86AudioStop,exec,mpc stop

# -- Screenshots --
bind=,Print,exec,hyprshot -m output -o ~/Pictures/Screenshots -- imv
bind=SUPER,Print,exec,hyprshot -m window -o ~/Pictures/Screenshots -- imv
bind=CTRL,Print,exec,flameshot gui --raw -p ~/Pictures/Screenshots | wl-copy

# Focus
bind=SUPER,left,movefocus,l
bind=SUPER,right,movefocus,r
bind=SUPER,up,movefocus,u
bind=SUPER,down,movefocus,d

# Move
bind=SUPERSHIFT,left,movewindow,l
bind=SUPERSHIFT,right,movewindow,r
bind=SUPERSHIFT,up,movewindow,u
bind=SUPERSHIFT,down,movewindow,d

# Resize
bind=SUPERCTRL,left,resizeactive,-20 0
bind=SUPERCTRL,right,resizeactive,20 0
bind=SUPERCTRL,up,resizeactive,0 -20
bind=SUPERCTRL,down,resizeactive,0 20

# Workspaces
bind=SUPER,1,workspace,1
bind=SUPER,2,workspace,2
bind=SUPER,3,workspace,3
bind=SUPER,4,workspace,4
bind=SUPER,5,workspace,5
bind=SUPER,6,workspace,6
bind=SUPER,7,workspace,7
bind=SUPER,8,workspace,8
bind=SUPER,9,workspace,9
bind=SUPER,0,workspace,10

# Send to Workspaces
bind=SUPERSHIFT,1,movetoworkspace,1
bind=SUPERSHIFT,2,movetoworkspace,2
bind=SUPERSHIFT,3,movetoworkspace,3
bind=SUPERSHIFT,4,movetoworkspace,4
bind=SUPERSHIFT,5,movetoworkspace,5
bind=SUPERSHIFT,6,movetoworkspace,6
bind=SUPERSHIFT,7,movetoworkspace,7
bind=SUPERSHIFT,8,movetoworkspace,8
bind=SUPERSHIFT,9,movetoworkspace,9
bind=SUPERSHIFT,0,movetoworkspace,10

bind=SUPER,mouse_down,workspace,e+1
bind=SUPER,mouse_up,workspace,e-1

#-- Startup ----------------------------------------------------
exec-once=~/.config/hypr/scripts/startup

# -- Fcitx5 input method
windowrule=pseudo,class:^(fcitx)$    # enable this will make fcitx5 works, but fcitx5-configtool will not work!
exec-once=cp ~/.config/fcitx5/profile-bak ~/.config/fcitx5/profile    # restore fcitx5 profile managed by nixos
exec-once=fcitx5 -d --replace     # start fcitx5 daemon
bind=ALT,E,exec,pkill fcitx5 -9;sleep 1;fcitx5 -d --replace; sleep 1;fcitx5-remote -r

