# Monitor settings
#monitor=DP-1,2560x1440@60,0x0,1 # external monitor at desk
monitor=eDP-1,1920x1080@60,0x0,1 # built-in display
monitor=HDMI-A-1,1920x1080@60,auto,1,mirror, eDP-1 # mirror external monitor at desk - for laptop
monitor=,preferred,auto,1,mirror, eDP-1  # default treatment for external monitors
#monitor=,preferred,auto,1 # default treatment for external monitors

# Environment variables
env = PATH,$PATH:$HOME/.local/bin:$HOME/.cargo/bin
env = XDG_CURRENT_DESKTOP,Hyprland
env = XDG_SESSION_TYPE,wayland
env = XDG_SESSION_DESKTOP,Hyprland

env = WLR_NO_HARDWARE_CURSORS,1
env = GDK_BACKEND, wayland,x11
env = GTK_THEME,Materia:dark
env = QT_QPA_PLATFORM,wayland;xcb
env = QT_QPA_PLATFORMTHEME,qt6ct
env = SDL_VIDEODRIVER,wayland

env = XCURSOR_SIZE,24
env = XCURSOR_THEME,Bibata

#auto-runs
exec-once = /home/liamm/.config/hypr/xdg-portal-hyprland
exec-once = wl-clipboard-history -t
exec-once = swww init 
exec-once = waybar
exec-once = wl-paste -p --watch wl-copy -p ''


# IF ABANDONING ABOVE METHODS, UNCOMMENT BELOW
#exec-once = swaylock
#exec-once = xss-lock -- swaylock -n -i /usr/share/pixmaps/background.jpg

exec-once = fcitx5 -d
exec-once = dunst
exec-once = blueman-applet

# set $gnome-schema org.gnome.desktop.interface
exec-once = gsettings set $gnome-schema gtk-theme 'Arc Dark'
exec-once = gsettings set $gnome-schema icon-theme 'Arc Dark'

# exec-once = /usr/bin/emacs --daemon
# exec-once = blueman-applet
exec-once = nm-applet
exec-once = kdeconnect-indicator 

$lock = swaylock -C $HOME/.config/swaylock/config
exec-once = swayidle -w timeout 180 'if pgrep -x swaylock; then systemctl suspend; fi' before-sleep '$lock' &
# Lock screen after idle for 300s and turn monitors off after 330
exec-once = swayidle -w timeout 300 '$lock' timeout 330 'hyprctl dispatch dpms off' resume 'hyprctl dispatch dpms on' &

input {
    kb_layout = us
    kb_variant =
    kb_model =
    kb_options =
    kb_rules =

    follow_mouse = 1
    numlock_by_default = true

    touchpad {
        disable_while_typing = true
        #disable_while_typing = false
        natural_scroll = yes
        middle_button_emulation = true
        drag_lock = false
        tap-to-click = true
    }

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

general {
    gaps_in = 2
    gaps_out = 4
    border_size = 2
    #col.active_border = rgba(ef629fee) rgba(eecda3ff) 45deg
    #col.active_border = rgba(b90efaff) rgba(f0fe2fee) 45deg
    col.active_border = rgba(00ffb2ff) rgba(00ff66ff) 90deg
    col.inactive_border = rgba(595959ff)

    layout = dwindle
}

group {

}

decoration {
    rounding = 10

   blur {
       enabled = true
       size = 3
       passes = 1
       xray = true
       new_optimizations = on
   }

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

animations {
    enabled = yes

    bezier = myBezier, 0.05, 0.9, 0.1, 1.05

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

dwindle {
    pseudotile = yes 
    preserve_split = yes 
}

master {
    new_is_master = true
}

gestures {
    workspace_swipe = true
    workspace_swipe_numbered = true
}

misc {
    disable_hyprland_logo = false
    #force_default_wallpaper = -1
}

# device:epic mouse V1 {
#     sensitivity = -0.5
# }


# Window Rules 
# - General Rules
windowrule = idleinhibit fullscreen, firefox
windowrule = idleinhibit focus, firefox
windowrule = idleinhibit fullscreen, floorp
windowrule = idleinhibit fullscreen, ghostty
windowrule = idleinhibit focus, mpv
windowrule = idleinhibit focus, ^(emacs)$ 
windowrule = idleinhibit focus, ^(Emacs)$ 
windowrule = idleinhibit focus, ^(discord)$ 
windowrule = idleinhibit focus, ^(Discord)$ 
windowrule = float, polkit-kde-authentication-agent-1
windowrule = float, ^(praat)$
windowrule = float, ^(network)$
windowrule = float, ^(nm-)$
windowrule = float, ^(Network)$
windowrule = float, Rofi
windowrule = float, Gimp
windowrule = float, Nautilus
windowrule = float, notification
windowrule = float, ^(launcher)$
windowrule = tile, Spotify
windowrule = tile, Minecraft
# - Workspace Rules
windowrule = workspace 2, KeePassXC
windowrule = workspace 3, firefox
windowrule = workspace 3, floorp
windowrule = workspace 4, Spotify
windowrule = workspace 6, discord
windowrule = workspace 6, Signal
windowrule = workspace 10, Minecraft
# - Opacity Rules
#windowrule = opacity 1.0 override 0.6, firefox
windowrule = opacity 1.0, firefox
windowrule = opacity 1.0 override 0.6,^(kitty)$ 
windowrule = opacity 1.0 override 0.6, alacritty


$mainMod = SUPER
$altMod = ALT
$ctrlMod = CTRL

# NATIVE PROGRAM BINDS
bind = $altMod, Return, exec, $HOME/.local/bin/ghostty
bind = $mainMod, Return, exec, $HOME/.local/bin/ghostty # for apps that yoink alt- binds
bind = $altMod SHIFT, Return, exec, alacritty
bind = $mainMod SHIFT, D, exec, discord --enable-blink-features=MiddleClickAutoscroll
bind = $mainMod SHIFT, E, exec, emacsclient -c -a 'emacs'
bind = $mainMode SHIFT, F, exec, focus-linux
bind = $mainMod, SPACE, exec, pkill wofi || wofi
bind = $mainMod, E, exec, nautilus

# SUPER alone to open wofi - hit again to kill
#bindr = $mainMod, $mainMod_L, exec, pkill wofi || wofi --show drun

# SUBMAPS
#
# Resize Submap
bind = $mainMod, R, submap, resize
submap = resize
bind=, escape,submap,reset


binde=, left, resizeactive, -10 0
bindr=, left, submap, reset
binde=, right, resizeactive, 10 0
bindr=, right, submap, reset
binde=, up, resizeactive, 0 10
bindr=, up, submap, reset
binde=, down, resizeactive, 0 -10
bindr=, down, submap, reset

binde=, H, resizeactive, -10 0
bindr=, H, submap, reset
binde=, J, resizeactive, 0 -10
bindr=, J, submap, reset
binde=, K, resizeactive, 0 10
bindr=, K, submap, reset
binde=, L, resizeactive, 10 0
bindr=, L, submap, reset

submap=reset

# Browser Submap
bind = $mainMod, B, submap, browser_select
submap = browser_select

bind =, B, exec, brave --enable-blink-features=MiddleClickAutoscroll
bind =, B, submap, reset

bind =, F, exec, firefox
bind =, F, submap, reset

bind=, escape,submap,reset
submap=reset

# Flatpak Binds
bind = $mainMod, S, exec, spotify

bind = $mainMod SHIFT, V, submap, video_stuff
submap = video_stuff
bind = , O, exec, flatpak run obs
bind = , O, submap, reset
bind = , V, exec , flatpak run kdenlive
bind = , V, submap, reset

bind=, escape,submap,reset
submap = reset

bind = $mainMod, P, pseudo, # dwindle

# Script Binds
bind = $mainMod, W, exec, ~/scripts/wp
bind = $mainMod SHIFT, W, exec, ~/scripts/bar_and_wp

# Other Binds
bind = $mainMod, C, killactive, 
bind = $mainMod control, Q, exec, $lock
bind = $mainMod, F4, exit, 
bind = $mainMod, V, togglefloating, 
bind = $mainMod SHIFT, S, togglesplit, # dwindle
bind = $mainMod, F, fullscreen,

# Screenshots
$screenshotarea = hyprctl keyword animation "fadeOut,0,0,default"; grimblast --notify copy area; hyprctl keyword animation "fadeOut,1,4,default"
bind = , Print, exec, $screenshotarea
bind = SHIFT, Print, exec, grimblast --notify --cursor copy output

# Multimedia Keys

# pause/play, next/prev audio
bindl =, XF86AudioPlay, exec, playerctl play-pause
bindl =, XF86AudioNext, exec, playerctl next
bindl =, XF86AudioPrev, exec, playerctl previous

# volume control
bindel=, XF86AudioRaiseVolume, exec, pamixer -i 5
bindel=, XF86AudioLowerVolume, exec, pamixer -d 5
bindel=, XF86AudioMute, exec, pamixer -t

# brightness control
binde=, XF86MonBrightnessDown, exec, brightnessctl set 10%-
binde=, XF86MonBrightnessUp, exec, brightnessctl set 10%+

# touchpad/other
binde=, XF86TouchpadToggle, exec, ~/scripts/hypr-tp-toggle
bind=, XF86Sleep, exec, systemctl suspend

# Window and Workspace Control

# Move focus with mainMod + hjkl
bind = $mainMod, H, movefocus, l
bind = $mainMod, L, movefocus, r
bind = $mainMod, K, movefocus, u
bind = $mainMod, J, movefocus, d
bind = $mainMod, comma, focusmonitor, -1
bind = $mainMod, period, focusmonitor, +1

# Move Windows 
bind = $mainMod SHIFT, H, movewindow, l
bind = $mainMod SHIFT, L, movewindow, r
bind = $mainMod SHIFT, K, movewindow, u
bind = $mainMod SHIFT, J, movewindow, d
bind = $mainMod SHIFT, comma, movecurrentworkspacetomonitor, -1
bind = $mainMod SHIFT, period, movecurrentworkspacetomonitor, +1
# Resize Windows
binde = $mainMod, right, resizeactive, 10 0
binde = $mainMod, left, resizeactive, -10 0
binde = $mainMod, up, resizeactive, 0 -10
binde = $mainMod, down, resizeactive, 0 10

# 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

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

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

# Tab through existing workspaces
bind = $mainMod, Tab, workspace, e+1
bind = $mainMod SHIFT, Tab, workspace, e-1

bind = $mainMod CTRL, right, workspace, +1
bind = $mainMod CTRL, left, workspace, -1

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