# Hyprland config - converted from i3 config by Adam French
# https://wiki.hyprland.org/Configuring/

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

monitor=,preferred,auto,1


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

$terminal = kitty
$fileManager = kitty -e ranger
$menu = wofi --show run

###################
###   CURSOR    ###
###################

env = XCURSOR_THEME,Miku Cursor
env = XCURSOR_SIZE,32

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

exec-once = fcitx5
exec-once = /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1
exec-once = nm-applet
exec-once = clipit
exec-once = dunst
exec-once = hypridle          # replaces xautolock; configure lock in hypridle.conf
exec-once = waterfox
exec-once = steam
exec-once = surfshark
exec-once = waybar
# exec-once = volctl           # may need a Wayland-compatible tray volume tool
# exec-once = pamac-tray       # check for Wayland support
# NOTE: ff-theme-util and fix_xcursor are X11-specific; drop or find Wayland equivalents
# Caps<->Escape swap is handled below via input config


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

env = XCURSOR_SIZE,24
env = HYPRCURSOR_SIZE,24


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

general {
    gaps_in = 5           # inner gaps (i3: gaps inner 10 → split between two sides)
    gaps_out = 0          # outer gaps (i3: gaps outer 0)
    border_size = 1

    col.active_border = rgb(C792EA)
    col.inactive_border = rgb(6272A4)

    resize_on_border = true
    allow_tearing = false
    layout = master       # closest to i3's stacking default; use dwindle for split
}

decoration {
    rounding = 0

    active_opacity = 1.0
    inactive_opacity = 1.0

    shadow {
        enabled = false
    }

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

animations {
    enabled = true

    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
}

master {
    new_status = slave
}

misc {
    force_default_wallpaper = 0
    disable_hyprland_logo = true
    focus_on_activate = true    # replaces i3's "for_window [urgent=latest] focus"
}


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

input {
    kb_layout = gb
    kb_options = caps:swapescape
    follow_mouse = 1
    sensitivity = 0
}

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

$mod = SUPER

# Terminal
bind = $mod, Return, exec, $terminal

# Kill focused window
bind = $mod SHIFT, Q, killactive

# Launcher (wofi replaces dmenu)
bind = $mod, D, exec, wofi --show run --style ~/scripts/wofi/wofi_style.css
# To approximate your dmenu colors, configure wofi's style.css

# Pavucontrol
bind = $mod CTRL, M, exec, pavucontrol

# Applications
bind = $mod, F2, exec, waterfox
bind = $mod, F3, exec, $fileManager
bind = $mod SHIFT, F3, exec, pcmanfm
bind = $mod, F5, exec, kitty -e mocp

# Compositor toggle (picom → hyprland manages its own compositor; these are no-ops)
# bind = $mod, T, exec, pkill picom
# bind = $mod CTRL, T, exec, picom -b

# Restart dunst
bind = $mod SHIFT, D, exec, killall dunst && notify-send 'restart dunst'

# Screenshots (flameshot on Wayland needs -g flag or use grim/slurp instead)
bind = , Print, exec, flameshot gui
bind = $mod, Print, exec, grim -g "$(slurp)" - | wl-copy
bind = $mod SHIFT, Print, exec, grim -g "$(slurp)" ~/screenshot.png

# Xkill equivalent
bind = $mod CTRL, X, exec, hyprctl kill

# Lock screen
bind = $mod, 9, exec, hyprlock    # replaces blurlock; configure hyprlock separately

# Toggle bar visibility (waybar)
bind = $mod, M, exec, pkill -SIGUSR1 waybar

# Reload Hyprland config
bind = $mod SHIFT, C, exec, hyprctl reload

# Exit Hyprland
bind = $mod SHIFT, E, exec, hyprctl dispatch exit

# System mode (replaces i3's $mode_system)
# Simple submap equivalent:
bind = $mod, 0, submap, system
submap = system
bind = , L, exec, hyprlock
bind = , L, submap, reset
bind = , S, exec, systemctl suspend
bind = , S, submap, reset
bind = , H, exec, systemctl hibernate
bind = , H, submap, reset
bind = , R, exec, systemctl reboot
bind = , R, submap, reset
bind = SHIFT, S, exec, systemctl poweroff
bind = SHIFT, S, submap, reset
bind = , E, exec, hyprctl dispatch exit
bind = , E, submap, reset
bind = , Return, submap, reset
bind = , Escape, submap, reset
submap = reset

# --- FOCUS ---
bind = $mod, H, movefocus, l
bind = $mod, J, movefocus, d
bind = $mod, K, movefocus, u
bind = $mod, L, movefocus, r
bind = $mod, left,  movefocus, l
bind = $mod, down,  movefocus, d
bind = $mod, up,    movefocus, u
bind = $mod, right, movefocus, r

# --- MOVE WINDOWS ---
bind = $mod SHIFT, H, movewindow, l
bind = $mod SHIFT, J, movewindow, d
bind = $mod SHIFT, K, movewindow, u
bind = $mod SHIFT, L, movewindow, r
bind = $mod SHIFT, left,  movewindow, l
bind = $mod SHIFT, down,  movewindow, d
bind = $mod SHIFT, up,    movewindow, u
bind = $mod SHIFT, right, movewindow, r

# --- FLOATING ---
bind = $mod SHIFT, space, togglefloating
bind = $mod, space, focusurgentorlast     # approximate focus mode_toggle

# --- FULLSCREEN ---
bind = $mod, F, fullscreen, 0

# --- SPLIT / LAYOUT ---
# Hyprland uses dwindle preselect or master swaps; approximate below:
bind = $mod, G, layoutmsg, orientationleft      # tile horizontally
bind = $mod, V, layoutmsg, orientationbottom    # tile vertically
bind = $mod, E, layoutmsg, togglesplit

# --- STICKY (pin floating window) ---
bind = $mod SHIFT, S, pin

# --- SCRATCHPAD ---
bind = $mod SHIFT, minus, movetoworkspacesilent, special:scratchpad
bind = $mod, minus, togglespecialworkspace, scratchpad

# --- WORKSPACE NAVIGATION ---
bind = $mod CTRL, right, workspace, +1
bind = $mod CTRL, left,  workspace, -1
bind = $mod, B, workspace, previous    # back_and_forth

# Switch to workspace
bind = $mod, 1, workspace, 1
bind = $mod, 2, workspace, 2
bind = $mod, 3, workspace, 3
bind = $mod, 4, workspace, 4
bind = $mod, 5, workspace, 5
bind = $mod, 6, workspace, 6
bind = $mod, 7, workspace, 7
bind = $mod, 8, workspace, 8

# Move container to workspace (silent = don't follow)
bind = $mod CTRL, 1, movetoworkspacesilent, 1
bind = $mod CTRL, 2, movetoworkspacesilent, 2
bind = $mod CTRL, 3, movetoworkspacesilent, 3
bind = $mod CTRL, 4, movetoworkspacesilent, 4
bind = $mod CTRL, 5, movetoworkspacesilent, 5
bind = $mod CTRL, 6, movetoworkspacesilent, 6
bind = $mod CTRL, 7, movetoworkspacesilent, 7
bind = $mod CTRL, 8, movetoworkspacesilent, 8

# Move to workspace AND follow (replaces $mod+Shift+N in i3)
bind = $mod SHIFT, 1, movetoworkspace, 1
bind = $mod SHIFT, 2, movetoworkspace, 2
bind = $mod SHIFT, 3, movetoworkspace, 3
bind = $mod SHIFT, 4, movetoworkspace, 4
bind = $mod SHIFT, 5, movetoworkspace, 5
bind = $mod SHIFT, 6, movetoworkspace, 6
bind = $mod SHIFT, 7, movetoworkspace, 7
bind = $mod SHIFT, 8, movetoworkspace, 8

# --- RESIZE SUBMAP ---
bind = $mod, R, submap, resize
submap = resize
binde = , H, resizeactive, -20 0
binde = , J, resizeactive, 0 20
binde = , K, resizeactive, 0 -20
binde = , L, resizeactive, 20 0
binde = , left,  resizeactive, -30 0
binde = , down,  resizeactive, 0 30
binde = , up,    resizeactive, 0 -30
binde = , right, resizeactive, 30 0
bind = , Return, submap, reset
bind = , Escape, submap, reset
submap = reset

# --- MOUSE BINDS ---
bindm = $mod, mouse:272, movewindow     # mod+LMB drag to move floating
bindm = $mod, mouse:273, resizewindow   # mod+RMB drag to resize

# --- AUDIO ---
bindel = , XF86AudioRaiseVolume, exec, pactl set-sink-volume @DEFAULT_SINK@ +10%
bindel = , XF86AudioLowerVolume, exec, pactl set-sink-volume @DEFAULT_SINK@ -10%
bindl  = , XF86AudioMute,        exec, pactl set-sink-mute @DEFAULT_SINK@ toggle
bindl  = , XF86AudioMicMute,     exec, pactl set-source-mute @DEFAULT_SOURCE@ toggle

# --- BRIGHTNESS ---
bindel = , XF86MonBrightnessUp,   exec, brightnessctl set +5%
bindel = , XF86MonBrightnessDown, exec, brightnessctl set 5%-


####################
### WINDOW RULES ###
####################

windowrule {
    name = Surfshark
    match:class = ^(Surfshark)$
    workspace = 8 silent
    tile = on
}


##############################
### WORKSPACE NAMES / ICONS ##
##############################

# Hyprland workspace names (replaces i3 set $ws variables)
# These are used by waybar's workspaces module — configure names there.
# ws1=ツ  ws2=ಠ‿ಠ  ws3=◕‿◕  ws4=ʘ‿ʘ
# ws5=˘◡˘ ws6=◠‿◠  ws7=ᵔᴥᵔ  ws8=æ


##############################
### COLORS (reference only) ##
##############################

# Your theme palette for use in waybar / wofi CSS:
# Background:   #1A1B2F
# Accent 1:     #C792EA  (purple)
# Accent 2:     #FF79C6  (pink)
# Accent 3:     #82AAFF  (blue)
# Inactive:     #6272A4
# Surface:      #2A2B3D


#####################################
### NOTES ON MIGRATING FROM i3     ##
#####################################
# 1. BAR: Replace i3bar+i3status with waybar. Copy the color palette above
#    into your waybar style.css. Workspace icon names go in waybar config.
#
# 2. LOCK: Replace blurlock with hyprlock. Configure in ~/.config/hypr/hyprlock.conf
#    Replace xautolock with hypridle in ~/.config/hypr/hypridle.conf (30 min timeout).
#
# 3. LAUNCHER: wofi replaces dmenu. Style with ~/.config/wofi/style.css using
#    your palette colors above.
#
# 4. SCREENSHOTS: grim + slurp replace i3-scrot on Wayland. flameshot also
#    works with the -g flag on some setups.
#
# 5. STACKING layout: Set layout = master above (or dwindle). Hyprland has no
#    direct stacking mode; use floating or master layout as closest equivalent.
#
# 6. GAP MODE: Replace the i3-gaps mode with direct hyprctl commands if needed:
#    hyprctl keyword general:gaps_in 10
#
# 7. BORDER TOGGLE ($mod+u/y/n): Use windowrulev2 or hyprctl at runtime:
#    hyprctl keyword general:border_size 0
