# Environment variables
env = GDK_BACKEND, wayland,x11
env = MOZ_ENABLE_WAYLAND, 1
env = MOZ_USE_XINPUT2, 1
env = QT_QPA_PLATFORM, wayland;xcb
env = SDL_VIDEODRIVER, wayland
env = XDG_CURRENT_DESKTOP, Hyprland
env = XDG_SESSION_DESKTOP, Hyprland
env = XDG_SESSION_TYPE, wayland

# Enable prefer-dark color-scheme setting
exec-once = gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'

# Autostart
## Apps
exec-once = discord
exec-once = steam
exec-once = nm-applet

## Services
exec-once = /usr/lib/polkit-kde-authentication-agent-1 # Authentication
exec-once = gammastep -l $(cat ~/.latlon) -t 6500K:3500K # Night light
exec-once = mako # Notifications
exec-once = udiskie & # Drive mounting
exec-once = waybar # Bar

# Wallpaper
exec-once = cp -f ~/Pictures/Wallpapers/$(ls ~/Pictures/Wallpapers -b | shuf -n 1) ~/.wallpaper
exec-once = swaybg -i ~/.wallpaper -m fill

# Idle and locking
$LOCK_CMD = swaylock -fF -i ~/.wallpaper -s fill --clock --effect-blur 5x1 --indicator
exec-once = swayidle -w timeout 300 "$LOCK_CMD --grace 300 --fade-in 0.5" timeout 600 "hyprctl dispatch dpms off" resume "hyprctl dispatch dpms on" before-sleep "$LOCK_CMD"

# Window rules
windowrulev2 = idleinhibit fullscreen, class:(discord) # Discord fullscreen idle inhibit
windowrulev2 = idleinhibit fullscreen, class:(firefox) # Firefox fullscreen idle inhibit
windowrulev2 = workspace 3, class:(discord) # Move Steam to workspace 9
windowrulev2 = workspace 4, class:(steam) # Move Steam to workspace 9

## XWaylandVideoBridge
windowrulev2 = noanim, class:^(xwaylandvideobridge)$
windowrulev2 = nofocus, class:^(xwaylandvideobridge)$
windowrulev2 = noinitialfocus, class:^(xwaylandvideobridge)$
windowrulev2 = opacity 0.0 override 0.0 override, class:^(xwaylandvideobridge)$

# Output configuration
monitor = , preferred, auto, 1 # Wildcard
monitor = desc:AOC 27G2G4 GYGL9HA232568, highrr, auto, 1, vrr,1
monitor = eDP-1, preferred, auto, 1.25 # Laptop

# Input configuration
input {
    kb_layout = us

    follow_mouse = 0

    touchpad {
        clickfinger_behavior = true
        disable_while_typing = false
        drag_lock = true
        natural_scroll = true
        tap-and-drag = true
    }

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

gestures {
    workspace_swipe = true
}

device:logitech-g703-ls-1 {
    accel_profile = flat
}

# Window configuration
general {
    gaps_in = 4
    gaps_out = 8
    border_size = 2
    col.active_border = rgba(c0caf5ff)
    col.inactive_border = rgba(1a1b26ff)

    layout = master
}

decoration {
    blur {
        enabled = true
        size = 5
        passes = 1
    }

    drop_shadow = no
    inactive_opacity = 0.95
    rounding = 5
}

master {
    mfact = 0.6
    new_is_master = true
    new_on_top = true
}

misc {
    disable_hyprland_logo = true
}

# Bindings

## Exit Hyprland
bind = SUPER SHIFT, E, exit, 

## Close focused window
bind = SUPER SHIFT, Q, killactive, 

## Lock screen
bind = SUPER SHIFT, ESCAPE, exec, $LOCK_CMD --fade-in 0.5

## Launch applications
bind = SUPER, Return, exec, kitty # Terminal
bind = SUPER, D, exec, fuzzel # Menu
bind = SUPER, F, exec, kitty ranger # File browser
bind = CONTROL SHIFT, Escape, exec, kitty btop # Task monitor

## Screenshotting
$GRIM_DIR = ~/Pictures/Screenshots
bind = , Print, exec, GRIM_DEFAULT_DIR=$GRIM_DIR grim && notify-send "Captured screenshot" "Saved in $GRIM_DIR"
bind = ALT, Print, exec, GRIM_DEFAULT_DIR=$GRIM_DIR grim -g "$(slurp)" && notify-send "Captured screenshot" "Saved in $GRIM_DIR"

## Window movements
bind = SUPER, H, layoutmsg, swapprev
bind = SUPER, J, layoutmsg, cyclenext
bind = SUPER, K, layoutmsg, cycleprev
bind = SUPER, L, layoutmsg, swapnext
bind = SUPER SHIFT, Space, togglefloating, 
bind = SUPER, I, layoutmsg, focusmaster master
bind = SUPER SHIFT, I, layoutmsg, swapwithmaster

## Window layout
bind = SUPER, left, layoutmsg, orientationleft
bind = SUPER, down, layoutmsg, orientationbottom
bind = SUPER, up, layoutmsg, orientationtop
bind = SUPER, right, layoutmsg, orientationright

## Switch workspaces with SUPER + [0-9]
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

## Move active window to a workspace with SUPER + SHIFT + [0-9]
bind = SUPER SHIFT, 1, movetoworkspace, 1
bind = SUPER SHIFT, 2, movetoworkspace, 2
bind = SUPER SHIFT, 3, movetoworkspace, 3
bind = SUPER SHIFT, 4, movetoworkspace, 4
bind = SUPER SHIFT, 5, movetoworkspace, 5
bind = SUPER SHIFT, 6, movetoworkspace, 6
bind = SUPER SHIFT, 7, movetoworkspace, 7
bind = SUPER SHIFT, 8, movetoworkspace, 8
bind = SUPER SHIFT, 9, movetoworkspace, 9

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